horizon-cisco-ui/dev_install.sh
Rob Cresswell 86b0bce8cf Initial commit
This patch adds the core panels (Cisco Dashboard and Firewalls),
dev install script, basic documentation, and testing.

There is a fairly large amount of extra "stuff" left in, due to the
copy/paste nature of the setup. Specifically, the tests have a lot of
the horizon test code in which is unecessary, but temporary with the aim
of getting up and running quickly.

Change-Id: I5fdce186df09e1168e8d52abfec17e0c20a64031
Partially-Implements: blueprint initial-setup
2015-08-18 14:33:52 +01:00

132 lines
3.1 KiB
Bash
Executable File

#!/bin/sh
# Small script for installing Horizon plugins
# Defaults to Horizon IS installed at opt/stack/horizon
### Variables
# Change these for your specific plugin
DASHBOARD_FILE="horizon_cisco_ui/enabled/_6000_cisco.py" # Relative path
N1K_PANEL_FILE="horizon_cisco_ui/enabled/_6010_nexus1000v.py" # Relative path
# These are defaults, may be useful to change but can normally be left alone
HORIZON_DIR="/opt/stack/horizon"
### Functions
setup_horizon () {
echo "Is Horizon installed? [Y/n] ?"
read INSTALLED
case $INSTALLED in
[yY]|"")
set_directory
;;
[nN])
STACK_DIR="/opt/stack"
echo "Checking for presence of $STACK_DIR..."
if [ ! -d "$STACK_DIR" ] ; then
echo "$STACK_DIR not found. Creating (requires sudo)..."
sudo mkdir -p $STACK_DIR
sudo chown -R $USER $STACK_DIR
chmod 0755 $STACK_DIR
fi
echo "Checking for git..."
if command -v git >/dev/null 2>&1 ; then
git clone https://github.com/openstack/horizon.git /opt/stack/horizon
else
echo "Git is not available, but is required. Please install git."
exit 1
fi
;;
*)
echo "Input not recognised"
setup_horizon
;;
esac
}
set_directory () {
echo "Please enter your Horizon root directory. Leave blank for default [$HORIZON_DIR]:"
read CUSTOM_DIR
if [ ! -z "${CUSTOM_DIR// }" ] ; then
if [ $CUSTOM_DIR == /*/ ] ; then
HORIZON_DIR=$CUSTOM_DIR
elif [ $CUSTOM_DIR == */ ] ; then
HORIZON_DIR=/$CUSTOM_DIR
elif [ $CUSTOM_DIR == /* ] ; then
HORIZON_DIR=$CUSTOM_DIR/
else
HORIZON_DIR=/$CUSTOM_DIR/
fi
fi
}
copy_enabled_file () {
ENABLED_DIR=$HORIZON_DIR"/openstack_dashboard/enabled/"
if [ -d "$ENABLED_DIR" ] ; then
echo "\nCopying $DASHBOARD_FILE to $ENABLED_DIR..."
if cp $DASHBOARD_FILE $ENABLED_DIR ; then
echo "Copy succeeded"
else
echo "Copy failed"
exit 1
fi
fi
if [ -d "$ENABLED_DIR" ] ; then
echo "\nCopying $N1K_PANEL_FILE to $ENABLED_DIR..."
if cp $N1K_PANEL_FILE $ENABLED_DIR ; then
echo "Copy succeeded"
else
echo "Copy failed"
exit 1
fi
fi
}
install_plugin () {
echo "\nChecking for existing venv..."
if [ ! -d $HORIZON_DIR"/.venv" ] ; then
echo "No venv found"
python $HORIZON_DIR"/tools/install_venv.py"
else
echo "Existing venv found [$HORIZON_DIR/.venv]"
fi
echo "\nInstalling plugin..."
if $HORIZON_DIR/tools/with_venv.sh pip install -e . ; then
echo "Plugin installed"
else
echo "Plugin installation failed"
exit 1
fi
}
launch_horizon () {
cd $HORIZON_DIR
echo "\nChecking for settings file..."
if [ -f openstack_dashboard/local/local_settings.py ] ; then
echo "Settings file found [$PWD/openstack_dashboard/local/local_settings.py]"
else
echo "Settings file not found. Using default..."
cp openstack_dashboard/local/local_settings.py.example openstack_dashboard/local/local_settings.py
fi
echo "\nLaunching Horizon at 127.0.0.1:8080..."
./run_tests.sh --runserver 127.0.0.1:8080
}
### Execution
setup_horizon
install_plugin
copy_enabled_file
launch_horizon