Modify the installation script of nova and glance

Modify the installation script of nova and glance, include the README files.

Change-Id: I477d453526941be8caa3ee89ee20c575067c416b
This commit is contained in:
joey5678 2014-12-23 18:29:38 +08:00
parent 995258ecf8
commit 4886a8a246
7 changed files with 180 additions and 110 deletions

3
envrc Executable file
View File

@ -0,0 +1,3 @@
#set up where the openstack is installed, before running the installation script,
#it's better to run 'source envrc' .
export OPENSTACK_INSTALL_DIR=/usr/lib/python2.7/dist-packages

View File

@ -37,7 +37,7 @@ Installation
- Please install the python package: pexpect>=2.3 ( because we use pxssh for loginng and there is a bug in pxssh, see https://mail.python.org/pipermail/python-list/2008-February/510054.html, you should fix this before launch the service. ) - Please install the python package: pexpect>=2.3 ( because we use pxssh for loginng and there is a bug in pxssh, see https://mail.python.org/pipermail/python-list/2008-February/510054.html, you should fix this before launch the service. )
* **Manual Installation** * **Manual Installation**
- Please **make sure you have installed the glance patches in /juno-patches**.
- Make sure you have performed backups properly. - Make sure you have performed backups properly.
* **Manual Installation** * **Manual Installation**
@ -70,14 +70,13 @@ Installation
`python /usr/bin/glance-sync --config-file=/etc/glance/glance-sync.conf & ` `python /usr/bin/glance-sync --config-file=/etc/glance/glance-sync.conf & `
* **Automatic Installation** * **Automatic Installation**
0. run `source envrc`.
1. Enter the glance-patch installation dir: `cd ./tricircle/juno-patches/glance/glance_location_patch/installation` . 1. **make sure you have installed the glance patches in /juno-patches**: Enter the glance-patch installation dir: `cd ./tricircle/juno-patches/glance/glance_location_patch/installation` .
2. Optional, modify the shell script variable: `_PYTHON_INSTALL_DIR` . 2. Optional, modify the shell script variable: `_PYTHON_INSTALL_DIR` .
3. Run the install script: `sh install.sh` 3. Run the install script: `sh install.sh`
4. Enter the glancesync installation dir: `cd ./tricircle/glancesync/installation` . 4. Enter the glancesync installation dir: `cd ./tricircle/glancesync/installation` .
5. Modify the cascading&cascaded glances' store scheme configuration, which is in the file: `./tricircle/glancesync/etc/glance/glance_store.yaml` . 5. Modify the cascading&cascaded glances' store scheme configuration, which is in the file: `./tricircle/glancesync/etc/glance/glance_store.yaml` .
6. Optional, modify the config options in shell script: `sync_enabled=True`, `sync_server_port=9595`, `sync_server_host=127.0.0.1` with the proper values. 6. Run the install script: `sh install.sh`
7. Run the install script: `sh install.sh`
Configurations Configurations
-------------- --------------

View File

@ -14,10 +14,11 @@
# Copyright (c) 2014 Huawei Technologies. # Copyright (c) 2014 Huawei Technologies.
CURPATH=$(cd "$(dirname "$0")"; pwd) CURPATH=$(cd "$(dirname "$0")"; pwd)
_GLANCE_CONF_DIR="/etc/glance"
_GLANCE_API_CONF_FILE="glance-api.conf"
_GLANCE_SYNC_CMD_FILE="glance-sync" _GLANCE_SYNC_CMD_FILE="glance-sync"
_PYTHON_INSTALL_DIR="/usr/lib64/python2.6/site-packages" _PYTHON_INSTALL_DIR=${OPENSTACK_INSTALL_DIR}
if [ ! -n ${_PYTHON_INSTALL_DIR} ];then
_PYTHON_INSTALL_DIR="/usr/lib/python2.7/dist-packages"
fi
_GLANCE_DIR="${_PYTHON_INSTALL_DIR}/glance" _GLANCE_DIR="${_PYTHON_INSTALL_DIR}/glance"
# if you did not make changes to the installation files, # if you did not make changes to the installation files,
@ -28,8 +29,6 @@ _BACKUP_DIR="${_GLANCE_DIR}/glance-sync-backup"
_SCRIPT_LOGFILE="/var/log/glance/installation/install.log" _SCRIPT_LOGFILE="/var/log/glance/installation/install.log"
api_config_option_list="sync_enabled=True sync_server_port=9595 sync_server_host=127.0.0.1"
export PS4='+{$LINENO:${FUNCNAME[0]}}' export PS4='+{$LINENO:${FUNCNAME[0]}}'
ERRTRAP() ERRTRAP()
@ -61,92 +60,101 @@ function process_stop
fi fi
} }
function backup
{
log "checking previous installation..."
if [ -d "${_BACKUP_DIR}/glance" ] ; then
log "It seems glance cascading has already been installed!"
log "Please check README for solution if this is not true."
exit 1
fi
log "backing up current files that might be overwritten..."
mkdir -p "${_BACKUP_DIR}/glance"
mkdir -p "${_BACKUP_DIR}/etc/glance"
if [ $? -ne 0 ] ; then
rm -r "${_BACKUP_DIR}/glance"
rm -r "${_BACKUP_DIR}/etc"
log "Error in config backup, aborted."
exit 1
fi
}
function restart_services
{
log "restarting glance ..."
service glance-api restart
service glance-registry restart
process_stop "glance-sync"
python /usr/bin/glance-sync --config-file=/etc/glance/glance-sync.conf &
}
function preinstall
{
if [[ ${EUID} -ne 0 ]]; then
log "Please run as root."
exit 1
fi
if [ ! -d "/var/log/glance/installation" ]; then
mkdir -p /var/log/glance/installation
touch _SCRIPT_LOGFILE
fi
log "checking installation directories..."
if [ ! -d "${_GLANCE_DIR}" ] ; then
log "Could not find the glance installation. Please check the variables in the beginning of the script."
log "aborted."
exit 1
fi
if [ ! -f "${_CONF_DIR}/${_GLANCE_SYNC_CMD_FILE}" ]; then
log "Could not find the glance-sync file. Please check the variables in the beginning of the script."
log "aborted."
exit 1
fi
}
#
#Start to execute here
#
trap 'ERRTRAP $LINENO' ERR trap 'ERRTRAP $LINENO' ERR
if [[ ${EUID} -ne 0 ]]; then preinstall
log "Please run as root."
exit 1
fi
if [ ! -d "/var/log/glance/installation" ]; then
mkdir /var/log/glance/installation
touch _SCRIPT_LOGFILE
fi
cd `dirname $0`
log "checking installation directories..."
if [ ! -d "${_GLANCE_DIR}" ] ; then
log "Could not find the glance installation. Please check the variables in the beginning of the script."
log "aborted."
exit 1
fi
if [ ! -f "${_GLANCE_CONF_DIR}/${_GLANCE_API_CONF_FILE}" ] ; then
log "Could not find glance-api config file. Please check the variables in the beginning of the script."
log "aborted."
exit 1
fi
if [ ! -f "${_CONF_DIR}/${_GLANCE_SYNC_CMD_FILE}" ]; then
log "Could not find the glance-sync file. Please check the variables in the beginning of the script."
log "aborted."
exit 1
fi
log "checking previous installation..."
if [ -d "${_BACKUP_DIR}/glance" ] ; then
log "It seems glance cascading has already been installed!"
log "Please check README for solution if this is not true."
exit 1
fi
log "backing up current files that might be overwritten..."
mkdir -p "${_BACKUP_DIR}/glance"
mkdir -p "${_BACKUP_DIR}/etc"
mkdir -p "${_BACKUP_DIR}/etc/glance"
cp -rf "${_GLANCE_CONF_DIR}/${_GLANCE_API_CONF_FILE}" "${_BACKUP_DIR}/etc/glance/"
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
rm -r "${_BACKUP_DIR}/glance"
rm -r "${_BACKUP_DIR}/etc"
log "Error in config backup, aborted."
exit 1 exit 1
fi fi
backup
if [ $? -ne 0 ] ; then
exit 1
fi
log "copying in new files..." log "copying in new files..."
cp -r "${_CODE_DIR}" `dirname ${_GLANCE_DIR}` cp -r "${_CODE_DIR}" `dirname ${_GLANCE_DIR}`
cp -r "${_CONF_DIR}/glance" "/etc" cp -r "${_CONF_DIR}/glance" "/etc"
cp "${_CONF_DIR}/${_GLANCE_SYNC_CMD_FILE}" "/usr/bin/" cp "${_CONF_DIR}/${_GLANCE_SYNC_CMD_FILE}" "/usr/bin/"
#Config options
log "configurate the glance options which is in script/tricircle.cfg"
cd `dirname $0`/../../script
python config.py glance
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
log "Error in copying, aborted." log "configurate the glance options error."
log "Recovering original files..."
cp -r "${_BACKUP_DIR}/glance" `dirname ${_GLANCE_DIR}` && rm -r "${_BACKUP_DIR}/glance"
cp "${_BACKUP_DIR}/etc/glance/*.conf" `dirname ${_GLANCE_CONF_DIR}` && rm -r "${_BACKUP_DIR}/etc"
if [ $? -ne 0 ] ; then
log "Recovering failed! Please install manually."
fi
exit 1 exit 1
fi fi
cd -
log "updating config file..." restart_services
for option in $api_config_option_list
do
sed -i -e "/$option/d" "${_GLANCE_CONF_DIR}/${_GLANCE_API_CONF_FILE}"
sed -i -e "/DEFAULT/a $option" "${_GLANCE_CONF_DIR}/${_GLANCE_API_CONF_FILE}"
done
log "restarting glance ..."
service openstack-glance-api restart
service openstack-glance-registry restart
process_stop "glance-sync"
python /usr/bin/glance-sync --config-file=/etc/glance/glance-sync.conf &
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
log "There was an error in restarting the service, please restart glance manually." log "There was an error in restarting the service, please restart glance manually."
exit 1 exit 1
fi fi
log "Completed." log "Completed."
log "See README to get started."
exit 0 exit 0

View File

@ -14,15 +14,14 @@
# Copyright (c) 2014 Huawei Technologies. # Copyright (c) 2014 Huawei Technologies.
CURPATH=$(cd "$(dirname "$0")"; pwd) CURPATH=$(cd "$(dirname "$0")"; pwd)
_GLANCE_CONF_DIR="/etc/glance" _PYTHON_INSTALL_DIR=${OPENSTACK_INSTALL_DIR}
_GLANCE_API_CONF_FILE="glance-api.conf" if [ ! -n ${_PYTHON_INSTALL_DIR} ];then
_PYTHON_INSTALL_DIR="/usr/lib64/python2.6/site-packages" _PYTHON_INSTALL_DIR="/usr/lib/python2.7/dist-packages"
fi
_GLANCE_DIR="${_PYTHON_INSTALL_DIR}/glance" _GLANCE_DIR="${_PYTHON_INSTALL_DIR}/glance"
# if you did not make changes to the installation files, # if you did not make changes to the installation files,
# please do not edit the following directories. # please do not edit the following directories.
_CODE_DIR="${CURPATH}/../glance"
_CONF_DIR="${CURPATH}/../etc"
_PATCH_DIR="${CURPATH}/.." _PATCH_DIR="${CURPATH}/.."
_BACKUP_DIR="${_GLANCE_DIR}/glance-installation-backup" _BACKUP_DIR="${_GLANCE_DIR}/glance-installation-backup"
@ -43,6 +42,32 @@ function log()
echo "`date -u +'%Y-%m-%d %T.%N'`: $@" >> $_SCRIPT_LOGFILE echo "`date -u +'%Y-%m-%d %T.%N'`: $@" >> $_SCRIPT_LOGFILE
} }
function process_stop
{
PID=`ps -efw|grep "$1"|grep -v grep|awk '{print $2}'`
echo "PID is: $PID">>$_SCRIPT_LOGFILE
if [ "x${PID}" != "x" ]; then
for kill_id in $PID
do
kill -9 ${kill_id}
if [ $? -ne 0 ]; then
echo "[[stop glance-sync]]$1 stop failed.">>$_SCRIPT_LOGFILE
exit 1
fi
done
echo "[[stop glance-sync]]$1 stop ok.">>$_SCRIPT_LOGFILE
fi
}
function restart_services
{
log "restarting glance ..."
service glance-api restart
service glance-registry restart
process_stop "glance-sync"
python /usr/bin/glance-sync --config-file=/etc/glance/glance-sync.conf &
}
trap 'ERRTRAP $LINENO' ERR trap 'ERRTRAP $LINENO' ERR
if [[ ${EUID} -ne 0 ]]; then if [[ ${EUID} -ne 0 ]]; then
@ -57,18 +82,6 @@ fi
cd `dirname $0` cd `dirname $0`
log "checking installation directories..."
if [ ! -d "${_GLANCE_DIR}" ] ; then
log "Could not find the glance installation. Please check the variables in the beginning of the script."
log "aborted."
exit 1
fi
if [ ! -f "${_GLANCE_CONF_DIR}/${_GLANCE_API_CONF_FILE}" ] ; then
log "Could not find glance-api config file. Please check the variables in the beginning of the script."
log "aborted."
exit 1
fi
log "checking previous installation..." log "checking previous installation..."
if [ -d "${_BACKUP_DIR}/glance" ] ; then if [ -d "${_BACKUP_DIR}/glance" ] ; then
@ -81,7 +94,6 @@ log "backing up current files that might be overwritten..."
mkdir -p "${_BACKUP_DIR}/glance" mkdir -p "${_BACKUP_DIR}/glance"
mkdir -p "${_BACKUP_DIR}/etc" mkdir -p "${_BACKUP_DIR}/etc"
mkdir -p "${_BACKUP_DIR}/etc/glance" mkdir -p "${_BACKUP_DIR}/etc/glance"
cp -rf "${_GLANCE_CONF_DIR}/${_GLANCE_API_CONF_FILE}" "${_BACKUP_DIR}/etc/glance/"
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
rm -r "${_BACKUP_DIR}/glance" rm -r "${_BACKUP_DIR}/glance"
@ -105,6 +117,13 @@ if [ $? -ne 0 ] ; then
exit 1 exit 1
fi fi
#restart services
restart_services
if [ $? -ne 0 ] ; then
log "There was an error in restarting the service, please restart glance manually."
exit 1
fi
log "Completed." log "Completed."
log "See README to get started." log "See README to get started."

View File

@ -14,7 +14,10 @@
# Copyright (c) 2014 Huawei Technologies. # Copyright (c) 2014 Huawei Technologies.
CURPATH=$(cd "$(dirname "$0")"; pwd) CURPATH=$(cd "$(dirname "$0")"; pwd)
_PYTHON_INSTALL_DIR="/usr/lib64/python2.6/site-packages" _PYTHON_INSTALL_DIR=${OPENSTACK_INSTALL_DIR}
if [ ! -n ${_PYTHON_INSTALL_DIR} ];then
_PYTHON_INSTALL_DIR="/usr/lib/python2.7/dist-packages"
fi
_GLANCE_STORE_DIR="${_PYTHON_INSTALL_DIR}/glance_store" _GLANCE_STORE_DIR="${_PYTHON_INSTALL_DIR}/glance_store"
# if you did not make changes to the installation files, # if you did not make changes to the installation files,
@ -36,6 +39,32 @@ function log()
echo "`date -u +'%Y-%m-%d %T.%N'`: $@" >> $_SCRIPT_LOGFILE echo "`date -u +'%Y-%m-%d %T.%N'`: $@" >> $_SCRIPT_LOGFILE
} }
function process_stop
{
PID=`ps -efw|grep "$1"|grep -v grep|awk '{print $2}'`
echo "PID is: $PID">>$_SCRIPT_LOGFILE
if [ "x${PID}" != "x" ]; then
for kill_id in $PID
do
kill -9 ${kill_id}
if [ $? -ne 0 ]; then
echo "[[stop glance-sync]]$1 stop failed.">>$_SCRIPT_LOGFILE
exit 1
fi
done
echo "[[stop glance-sync]]$1 stop ok.">>$_SCRIPT_LOGFILE
fi
}
function restart_services
{
log "restarting glance ..."
service glance-api restart
service glance-registry restart
process_stop "glance-sync"
python /usr/bin/glance-sync --config-file=/etc/glance/glance-sync.conf &
}
trap 'ERRTRAP $LINENO' ERR trap 'ERRTRAP $LINENO' ERR
if [[ ${EUID} -ne 0 ]]; then if [[ ${EUID} -ne 0 ]]; then
@ -60,8 +89,13 @@ fi
log "copying in new files..." log "copying in new files..."
cp -rf "${_CODE_DIR}" `dirname ${_PYTHON_INSTALL_DIR}` cp -rf "${_CODE_DIR}" ${_PYTHON_INSTALL_DIR}
restart_services
if [ $? -ne 0 ] ; then
log "There was an error in restarting the service, please restart glance manually."
exit 1
fi
log "Completed." log "Completed."
log "See README to get started." log "See README to get started."

View File

@ -40,6 +40,7 @@ We provide two ways to install the nova proxy code. In this section, we will gui
- Make sure you have performed backups properly. - Make sure you have performed backups properly.
- Navigate to the local repository and copy the contents in 'nova' sub-directory to the corresponding places in existing nova, e.g. - Navigate to the local repository and copy the contents in 'nova' sub-directory to the corresponding places in existing nova, e.g.
```cp -r $LOCAL_REPOSITORY_DIR/nova $NOVA_PARENT_DIR``` ```cp -r $LOCAL_REPOSITORY_DIR/nova $NOVA_PARENT_DIR```
(replace the $... with actual directory name.) (replace the $... with actual directory name.)
@ -70,6 +71,8 @@ We provide two ways to install the nova proxy code. In this section, we will gui
- Make sure you have performed backups properly. - Make sure you have performed backups properly.
- run `source envrc`
- Navigate to the installation directory and run installation script. - Navigate to the installation directory and run installation script.
``` ```
cd $LOCAL_REPOSITORY_DIR/installation cd $LOCAL_REPOSITORY_DIR/installation

View File

@ -15,7 +15,10 @@
_NOVA_CONF_DIR="/etc/nova" _NOVA_CONF_DIR="/etc/nova"
_NOVA_CONF_FILE="nova.conf" _NOVA_CONF_FILE="nova.conf"
_NOVA_INSTALL="/usr/lib64/python2.6/site-packages" _NOVA_INSTALL=${OPENSTACK_INSTALL_DIR}
if [ ! -n ${_NOVA_INSTALL} ];then
_NOVA_INSTALL="/usr/lib/python2.7/dist-packages"
fi
_NOVA_DIR="${_NOVA_INSTALL}/nova" _NOVA_DIR="${_NOVA_INSTALL}/nova"
# if you did not make changes to the installation files, # if you did not make changes to the installation files,
@ -25,7 +28,6 @@ _BACKUP_DIR="${_NOVA_INSTALL}/.nova-proxy-installation-backup"
_SCRIPT_LOGFILE="/var/log/nova-proxy/installation/install.log" _SCRIPT_LOGFILE="/var/log/nova-proxy/installation/install.log"
config_option_list="nova_admin_username=nova nova_admin_password=openstack nova_admin_tenant_name=service proxy_region_name=AZ1 cascading_nova_url=http://cascading_host:8774/v2 cascaded_nova_url=http://cascaded_host:8774/v2 cascaded_neutron_url=http://cascaded_host:9696 cascaded_glance_flag=False cascaded_glance_url=http://cascaded_host:9292 os_region_name=Cascading_Openstack keystone_auth_url=http://cascading_host:5000/v2.0/ cinder_endpoint_template=http://cascading_host:8776/v1/%(project_id)s compute_manager=nova.compute.manager_proxy.ComputeManager image_copy_dest_location_url=file:///var/lib/glance/images image_copy_dest_host=cascaded_host image_copy_dest_user=glance image_copy_dest_password=openstack image_copy_source_location_url=file:///var/lib/glance/images image_copy_source_host=copy_image_host image_copy_source_user=glance image_copy_source_password=openstack"
function log() function log()
{ {
@ -45,6 +47,11 @@ fi
cd `dirname $0` cd `dirname $0`
if [ ! -d "/var/log/nova-proxy/installation" ]; then
mkdir -p /var/log/nova-proxy/installation
touch _SCRIPT_LOGFILE
fi
log "checking installation directories..." log "checking installation directories..."
if [ ! -d "${_NOVA_DIR}" ] ; then if [ ! -d "${_NOVA_DIR}" ] ; then
log "Could not find the nova installation. Please check the variables in the beginning of the script." log "Could not find the nova installation. Please check the variables in the beginning of the script."
@ -87,19 +94,16 @@ if [ $? -ne 0 ] ; then
exit 1 exit 1
fi fi
log "updating config file..." cd `dirname $0`/../../script
for option in $config_option_list python config.py nova
do if [ $? -ne 0 ] ; then
option_key=`echo $option|awk -F "=" '{print $1}'` log "configurate the nova options error."
option_value=`echo $option|awk -F "=" '{print $2}'` exit 1
sed -i.backup -e "/$option_key *=/d" "${_NOVA_CONF_DIR}/${_NOVA_CONF_FILE}" fi
echo "$option_key,***************$option_value" cd -
echo $option_key=$option_value >> "${_NOVA_CONF_DIR}/${_NOVA_CONF_FILE}"
done
log "restarting nova compute..." log "restarting nova compute..."
service openstack-nova-compute restart service nova-compute restart
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
log "There was an error in restarting the service, please restart nova scheduler manually." log "There was an error in restarting the service, please restart nova scheduler manually."
exit 1 exit 1
@ -108,4 +112,4 @@ fi
log "Completed." log "Completed."
log "See README to get started." log "See README to get started."
exit 0 exit 0