solve yum error because we now prefer network repo to local yum
Change-Id: I71001d478d511f09281e0e12fb044e30dfff3077 Signed-off-by: luyao <lu.yao135@zte.com.cn>
This commit is contained in:
parent
e99e1a7771
commit
de63842d60
159
tools/setup/common/daisy_common_func.sh
Executable file → Normal file
159
tools/setup/common/daisy_common_func.sh
Executable file → Normal file
@ -1,10 +1,10 @@
|
||||
#!/bin/bash
|
||||
# 最高全局公用函数,可能会被所有其他脚本调用
|
||||
# global function,can be called by other script
|
||||
|
||||
#防止脚本重复被包含
|
||||
#avoid to be repeat include
|
||||
if [ ! "$_DAISY_COMMON_FUNC_FILE" ];then
|
||||
|
||||
#######################问答交互相关基本函数############################
|
||||
#######################get answer from user functions############################
|
||||
# get 'yes' or 'no' answer from user
|
||||
function read_bool
|
||||
{
|
||||
@ -25,7 +25,7 @@ function read_bool
|
||||
*)
|
||||
echo "Please input y or n"
|
||||
read_bool "$prompt" "$default";;
|
||||
|
||||
|
||||
esac
|
||||
return 0
|
||||
}
|
||||
@ -49,7 +49,7 @@ function read_string_input_null_check
|
||||
fi
|
||||
}
|
||||
|
||||
# 获取读取一个IP列表的功能
|
||||
#read ip list
|
||||
function read_iplist
|
||||
{
|
||||
local prompt=$1
|
||||
@ -60,12 +60,12 @@ function read_iplist
|
||||
echo -e "local ip list:"
|
||||
echo -e "$ip_list"
|
||||
echo -e "(recommend: $recommend): \c "
|
||||
fi
|
||||
fi
|
||||
read answer
|
||||
[ -z $answer ] && answer="$recommend"
|
||||
}
|
||||
|
||||
#######################配置读写相关基本函数############################
|
||||
#######################configuration functions############################
|
||||
|
||||
function get_config
|
||||
{
|
||||
@ -73,12 +73,10 @@ function get_config
|
||||
local key=$2
|
||||
|
||||
[ ! -e $file ] && return
|
||||
#忽略井号开头的注释行以及空行之后再grep过滤"key"所在的行
|
||||
local line=`sed '/^[[:space:]]*#/d' $file | sed /^[[:space:]]*$/d | grep -w "$key"| grep "$key[[:space:]]*=" -m1`
|
||||
if [ -z "$line" ]; then
|
||||
config_answer=""
|
||||
else
|
||||
#将第一个=号替换为空格,再删除第一个单词得到value
|
||||
config_answer=`echo $line | sed 's/=/ /' | sed -e 's/^\w*\ *//'`
|
||||
fi
|
||||
}
|
||||
@ -94,31 +92,31 @@ function update_config
|
||||
|
||||
#echo update key $key to value $value in file $file ...
|
||||
local exist=`grep "^[[:space:]]*[^#]" $file | grep -c "$key[[:space:]]*=[[:space:]]*.*"`
|
||||
#注意:如果某行是注释,开头第一个字符必须是#号!!!
|
||||
#action:If a line is a comment, the beginning of the first character must be a #!!!
|
||||
local comment=`grep -c "^[[:space:]]*#[[:space:]]*$key[[:space:]]*=[[:space:]]*.*" $file`
|
||||
|
||||
|
||||
if [[ $value == "#" ]];then
|
||||
if [ $exist -gt 0 ];then
|
||||
sed -i "/^[^#]/s/$key[[:space:]]*=/\#$key=/" $file
|
||||
sed -i "/^[^#]/s/$key[[:space:]]*=/\#$key=/" $file
|
||||
fi
|
||||
return
|
||||
fi
|
||||
|
||||
if [ $exist -gt 0 ];then
|
||||
#如果已经存在未注释的有效配置行,直接更新value
|
||||
#if there have been a effective configuration line did not comment, update value directly
|
||||
sed -i "/^[^#]/s#$key[[:space:]]*=.*#$key=$value#" $file
|
||||
|
||||
|
||||
elif [ $comment -gt 0 ];then
|
||||
#如果存在已经注释掉的对应配置行,则去掉注释,更新value
|
||||
#if there is a configuration line has been commented out, then remove the comments, update the value
|
||||
sed -i "s@^[[:space:]]*#[[:space:]]*$key[[:space:]]*=[[:space:]]*.*@$key=$value@" $file
|
||||
else
|
||||
#否则在末尾追加有效配置行
|
||||
#add effective configuration line at the end
|
||||
echo "$key=$value" >> $file
|
||||
fi
|
||||
}
|
||||
|
||||
#可以根据[section]的位置在后面插入key=value,或者只有key的字段
|
||||
#某些配置文件中存在value为空的开关量,此函数试用于value为空的情况,不会把value为空时时设置为错误。
|
||||
#accord to the location of the section insert key = value, or only a key field
|
||||
#this function isused in cases where the value is empty, will not raise error when the value is empty
|
||||
function update_section_config
|
||||
{
|
||||
local file=$1
|
||||
@ -128,7 +126,7 @@ function update_section_config
|
||||
|
||||
[ ! -e $file ] && return
|
||||
|
||||
#根据section搜寻文件中是否有某个key
|
||||
#find key according to section
|
||||
if [ -z $value ];then
|
||||
local exist=`sed -n "/\[$section\]/,/\[*\]/p" $file | grep "^[[:space:]]*[^#]" |grep -c "[[:space:]]*$key[[:space:]]*"`
|
||||
if [ $exist -eq 0 ];then
|
||||
@ -139,82 +137,93 @@ function update_section_config
|
||||
local exist=`sed -n "/\[$section\]/,/\[*\]/p" $file | grep "^[[:space:]]*[^#]" |grep -c "[[:space:]]*$key[[:space:]]*=[[:space:]]*"`
|
||||
if [ $exist -eq 0 ];then
|
||||
local linenumber=`grep -n "\[$section\]" $file| awk -F ':' '{print $1}'`
|
||||
sed -i "$linenumber a$key=$value" $file
|
||||
sed -i "$linenumber a$key=$value" $file
|
||||
else
|
||||
sed -i "/\[$section\]/,/\[*\]/s/[[:space:]]*$key[[:space:]]*=[[:space:]]*.*/$key=$value/g" $file
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
#获取文件中string的数量
|
||||
#get string number
|
||||
function get_string_num
|
||||
{
|
||||
local file=$1
|
||||
local string=$2
|
||||
|
||||
[ ! -e $file ] && { echo "$file doesn't exist."; exit 1; }
|
||||
#忽略井号开头的注释行以及空行之后再grep过滤"key"所在的行
|
||||
string_num=`sed '/^[[:space:]]*#/d' $file | sed /^[[:space:]]*$/d | grep -cw "$string"`
|
||||
}
|
||||
|
||||
#保存配置信息,指定配置文件安装方式和卸载不需要保存
|
||||
#调用本函数时应保证同一模块的配置参数一次性配置完,如不能先配置部分tc,然后配置cc,又回头配置tc
|
||||
#Save the configuration information, the configuration file of installation and uninstall don't need to save
|
||||
#when call this function,you should make sure one-time finish configuration module configuration parameters, if not,you can configuration part tc first, and then configure the cc, and back to tc
|
||||
function user_config_save
|
||||
{
|
||||
{
|
||||
local component="$1"
|
||||
local key="$2"
|
||||
local value="$3"
|
||||
|
||||
if [ "$operation" = "install" ];then
|
||||
#如果用户配置文件已经存在则备份旧的配置
|
||||
#If the user configuration file already exists, a backup the configuration of the old
|
||||
if [ ! -f $user_config_save_file ];then
|
||||
mkdir -p ${user_config_save_path}
|
||||
touch $user_config_save_file
|
||||
mkdir -p ${user_config_save_path}
|
||||
touch $user_config_save_file
|
||||
echo -e "## opencos installation configure file at ${current_time}" >$user_config_save_file
|
||||
echo -e "## you can edit it and install opencos by conf_file option, as \"./installopencos_(arch).bin conf_file /home/tecs_install/user_install.conf\"\n" >>$user_config_save_file
|
||||
echo -e "## global configration section\nmode=$mode\n">>$user_config_save_file
|
||||
echo -e "## component configration section">>$user_config_save_file
|
||||
fi
|
||||
# 如果,没有组件归属,则放在mode后
|
||||
# If there is no component belonging to, put it after on mode
|
||||
if [ "$component" = "" ];then
|
||||
[ "$key" = "" ] && { echo -e "\nkey is null, please check!"; exit 1; }
|
||||
sed -i "/mode=$mode/a $key=$value" $user_config_save_file
|
||||
else
|
||||
else
|
||||
[ -z "`cat $user_config_save_file |grep -w "\[$component\]"`" ] && echo -e "\n[$component]" >>$user_config_save_file
|
||||
[[ $key != "" ]] && echo "$key=$value" >>$user_config_save_file
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
#######################rpm包处理相关基本函数############################
|
||||
#######################rpm related functions############################
|
||||
|
||||
#判断某rpm包是否已安装
|
||||
#check rpm install
|
||||
function check_installed
|
||||
{
|
||||
has_installed="no"
|
||||
|
||||
|
||||
rpm -q $1 &>/dev/null
|
||||
|
||||
|
||||
if [ 0 == $? ];then
|
||||
has_installed="yes"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# 检查rpm包是否被依赖
|
||||
# check rpm depends
|
||||
function check_depend
|
||||
{
|
||||
local rpm_name=$1
|
||||
# 检测依赖包是否被别人使用
|
||||
# check if the rpm is used by someone else
|
||||
rpm -q --whatrequires $rpm_name &>/dev/null
|
||||
# 当查询不到被依赖的关系或rpm未安装,返回的是1,否则为0
|
||||
return "$?"
|
||||
}
|
||||
|
||||
# 安装包的函数
|
||||
# install rpm by yum
|
||||
function install_rpm_by_yum
|
||||
{
|
||||
local rpm_name=$1
|
||||
|
||||
yum install -y $rpm_name
|
||||
|
||||
local result=$?
|
||||
if [ $result -ne 0 ];then
|
||||
echo -e "\ninstall $rpm_name failed!"
|
||||
exit $result
|
||||
fi
|
||||
}
|
||||
# install rpm by daisy yum
|
||||
function install_rpm_by_daisy_yum
|
||||
{
|
||||
local rpm_name=$1
|
||||
|
||||
[[ $daisy_yum = "" ]] && { echo "yum repository doesn't create!"; exit 1; }
|
||||
$daisy_yum install $rpm_name
|
||||
|
||||
@ -222,10 +231,9 @@ function install_rpm_by_yum
|
||||
if [ $result -ne 0 ];then
|
||||
echo -e "\ninstall $rpm_name failed!"
|
||||
exit $result
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# 检测要安装的包是否存在,如果不存在,则提示是否需要安装
|
||||
# check existence of packge,if not, indicates whether need to install
|
||||
function check_and_install_rpm
|
||||
{
|
||||
local rpm_name=$1
|
||||
@ -240,7 +248,7 @@ function check_and_install_rpm
|
||||
fi
|
||||
}
|
||||
|
||||
# 检测要安装的包是否存在,如果不存在,则提示是否需要安装,如果存在,则需要升级
|
||||
# check existence of packge,if exist,there is a need to upgrade
|
||||
function install_or_upgrade_rpm
|
||||
{
|
||||
local rpm_name=$1
|
||||
@ -260,7 +268,7 @@ function install_or_upgrade_rpm
|
||||
fi
|
||||
}
|
||||
|
||||
# 检测是否协助RPM包,如果已经安装过了,提示是否要卸载
|
||||
# if packate have installed, suggest whether to unload
|
||||
function check_uninstall_tecs_rpm
|
||||
{
|
||||
local rpm_name=$1
|
||||
@ -268,7 +276,7 @@ function check_uninstall_tecs_rpm
|
||||
if [[ "$has_installed" == "no" ]];then
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
read_bool "$rpm_name already installed, remove it?" "no"
|
||||
if [ $answer == "yes" ]; then
|
||||
service_stop $rpm_name
|
||||
@ -290,9 +298,9 @@ function remove_rpms_by_yum
|
||||
|
||||
}
|
||||
|
||||
# 检测指定包是否需要升级
|
||||
#check packages need to upgrade
|
||||
function check_app_is_upgrade
|
||||
{
|
||||
{
|
||||
local app=$1
|
||||
is_update="yes"
|
||||
|
||||
@ -302,51 +310,50 @@ function check_app_is_upgrade
|
||||
fi
|
||||
}
|
||||
|
||||
# 升级包的函数
|
||||
# update rpm by yum
|
||||
function upgrade_rpms_by_yum
|
||||
{
|
||||
local app_list="$1"
|
||||
|
||||
|
||||
if [ "$app_list" = "" ];then
|
||||
echo -e "\nsorry, there is no rpm need to upgrade"!
|
||||
exit 0
|
||||
fi
|
||||
#此处如果把app_list作为upgrade的参数,如果有一个不需要升级或已被升级
|
||||
#过的daisy服务,会导致整个升级失败,因此这里写为把每个服务单独判断是否升级
|
||||
fi
|
||||
#need to upgrade separately for each service
|
||||
[ "$daisy_yum" = "" ] && { echo "opencos yum doesn't set, update rpms failed!"; exit 1; }
|
||||
for app in $app_list
|
||||
do
|
||||
check_app_is_upgrade "$app"
|
||||
if [[ "$is_update" == "yes" ]];then
|
||||
echo -e "\n$app will upgrade..."
|
||||
$daisy_yum upgrade $app
|
||||
if [[ "$is_update" == "yes" ]];then
|
||||
echo -e "\n$app will upgrade..."
|
||||
$daisy_yum upgrade $app
|
||||
local result=$?
|
||||
if [ $result -ne 0 ];then
|
||||
echo -e "\nupgrade $app failed,return $result"!
|
||||
exit $result
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo -e "\n$app don't need to upgrade"!
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#######################服务处理相关基本函数############################
|
||||
# 停止服务
|
||||
#######################service related functions############################
|
||||
# stop service
|
||||
function service_stop
|
||||
{
|
||||
local app=$1
|
||||
[ ! -f ${systemd_path}/$app.service ] && return
|
||||
|
||||
cd /
|
||||
systemctl stop $app.service &>/dev/null
|
||||
systemctl stop $app.service &>/dev/null
|
||||
cd - >/dev/null
|
||||
|
||||
|
||||
local service_status="active"
|
||||
local timeout=0
|
||||
while [ "$service_status" != "inactive" ]
|
||||
do
|
||||
do
|
||||
service_status=`systemctl show $app|grep -w ActiveState|awk -F '=' '{print $2}'`
|
||||
if [ "$service_status" = "inactive" ];then
|
||||
break
|
||||
@ -354,34 +361,34 @@ function service_stop
|
||||
timeout=$(($timeout+1))
|
||||
[ $timeout -gt 3 ] && { echo "warning: $app status is \"$service_status\" after stopping."; break; }
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
# 启动服务服务
|
||||
# start service
|
||||
function service_start
|
||||
{
|
||||
local app=$1
|
||||
[ ! -f ${systemd_path}/$app.service ] && return
|
||||
|
||||
#此处cd /与cd -不可去掉,为了处理安装后启动临时目录/tmp/selfgzxxxxxxxx删除的问题
|
||||
#cd / and cd -can't be removed ,in order to deal with deleting the temporary directory/TMP/selfgzxxxxxxxx
|
||||
cd /
|
||||
systemctl start $app.service >/dev/null
|
||||
cd - >/dev/null
|
||||
timeout=0
|
||||
timeout=0
|
||||
while [ `systemctl status $app.service|grep -c active` -eq 0 ]
|
||||
do
|
||||
do
|
||||
sleep 1
|
||||
timeout=$(($timeout+1))
|
||||
if [ $timeout -gt 3 ]; then
|
||||
echo "$app can not be started"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# 重启动服务服务
|
||||
# restart service
|
||||
function service_restart
|
||||
{
|
||||
local app=$1
|
||||
@ -392,17 +399,17 @@ function service_restart
|
||||
cd - >/dev/null
|
||||
}
|
||||
|
||||
# 根据询问结果来停止服务
|
||||
# according to the result of asking to stop the service
|
||||
function ask_service_stop
|
||||
{
|
||||
local app=$1
|
||||
[ ! -f ${systemd_path}/$app.service ] && return
|
||||
|
||||
read_bool "Stop service $app?" "yes"
|
||||
[ "$answer" == "yes" ] && systemctl stop $app.service >/dev/null
|
||||
[ "$answer" == "yes" ] && systemctl stop $app.service >/dev/null
|
||||
}
|
||||
|
||||
# 根据询问结果来启动服务
|
||||
# according to the result of asking to start the service
|
||||
function ask_service_start
|
||||
{
|
||||
local app=$1
|
||||
@ -427,7 +434,7 @@ function stop_service_all
|
||||
service_stop "daisy-orchestration"
|
||||
}
|
||||
|
||||
# 自动打开所有服务
|
||||
# start all the service automatically
|
||||
function start_service_all
|
||||
{
|
||||
service_start "mariadb"
|
||||
@ -441,4 +448,4 @@ function start_service_all
|
||||
}
|
||||
|
||||
_DAISY_COMMON_FUNC_FILE="common_func.sh"
|
||||
fi
|
||||
fi
|
||||
|
@ -1,7 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 提供yum设置相关函数
|
||||
|
||||
if [ ! "$_DAISY_YUM_FILE" ];then
|
||||
|
||||
function make_yum_server
|
||||
@ -11,14 +9,12 @@ function make_yum_server
|
||||
[ "$?" -ne 0 ] && { echo "createrepo in $path failed"; exit 1; }
|
||||
patch_path="/home/daisy_patch/"
|
||||
if [ -d $patch_path ];then
|
||||
#避免旧的repodata被破坏,导致createrepo命令失败
|
||||
[ -d $patch_path/repodata ] && rm -rf $patch_path/repodata
|
||||
createrepo --update $patch_path &>/dev/null
|
||||
[ "$?" -ne 0 ] && { echo "createrepo in $patch_path failed"; exit 1; }
|
||||
fi
|
||||
}
|
||||
|
||||
# 产生REPO客户端的文件
|
||||
function make_yum_client
|
||||
{
|
||||
path=`pwd`
|
||||
@ -56,6 +52,10 @@ function yum_set
|
||||
echo "creating yum repo, please wait for several seconds..."
|
||||
make_yum_server
|
||||
make_yum_client
|
||||
echo "creating epel yum repo, please wait for several seconds..."
|
||||
yum install epel-release
|
||||
echo "creating openstack mitaka yum repo, please wait for several seconds..."
|
||||
yum install centos-release-openstack-mitaka
|
||||
}
|
||||
|
||||
fi
|
||||
|
157
tools/setup/install/install_interface.sh
Executable file → Normal file
157
tools/setup/install/install_interface.sh
Executable file → Normal file
@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
# 提供和yum安装相关的公共函数和变量
|
||||
# provide yum related public functions and variables
|
||||
if [ ! "$_INSTALL_INTERFACE_FILE" ];then
|
||||
_INSTALL_INTERFACE_DIR=`pwd`
|
||||
cd $_INSTALL_INTERFACE_DIR/../common/
|
||||
@ -17,67 +17,73 @@ keystone_admin_token="e93e9abf42f84be48e0996e5bd44f096"
|
||||
daisy_install="/var/log/daisy/daisy_install"
|
||||
installdatefile=`date -d "today" +"%Y%m%d-%H%M%S"`
|
||||
install_logfile=$daisy_install/daisyinstall_$installdatefile.log
|
||||
#输出的内容既显示在屏幕上又输出到指定文件中
|
||||
#the contents of the output is displayed on the screen and output to the specified file
|
||||
function write_install_log
|
||||
{
|
||||
local promt="$1"
|
||||
echo -e "$promt"
|
||||
echo -e "`date -d today +"%Y-%m-%d %H:%M:%S"` $promt" >> $install_logfile
|
||||
}
|
||||
#安装
|
||||
#install function
|
||||
function all_install
|
||||
{
|
||||
echo "*******************************************************************************"
|
||||
echo "daisy will installed ..."
|
||||
echo "daisy will installed ..."
|
||||
echo "*******************************************************************************"
|
||||
|
||||
|
||||
if [ ! -d "$daisy_install" ];then
|
||||
mkdir -p $daisy_install
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -f "$install_logfile" ];then
|
||||
touch $install_logfile
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -rf /root/.my.cnf
|
||||
[ "$?" -ne 0 ] && { write_install_log "Error:can not rm of /root/.my.cnf file"; exit 1; }
|
||||
[ "$?" -ne 0 ] && { write_install_log "Error:can not rm of /root/.my.cnf file"; exit 1; }
|
||||
write_install_log "install fping rpm"
|
||||
install_rpm_by_yum "fping"
|
||||
|
||||
|
||||
write_install_log "install mariadb-galera-server rpm"
|
||||
install_rpm_by_yum "mariadb-galera-server"
|
||||
|
||||
|
||||
write_install_log "install mariadb rpm"
|
||||
install_rpm_by_yum "mariadb"
|
||||
|
||||
|
||||
write_install_log "install rabbitmq-server rpm"
|
||||
install_rpm_by_yum "rabbitmq-server"
|
||||
|
||||
|
||||
write_install_log "install keystone rpm"
|
||||
install_rpm_by_yum "openstack-keystone"
|
||||
|
||||
|
||||
write_install_log "install ironic rpm"
|
||||
install_rpm_by_yum "openstack-ironic-api openstack-ironic-common openstack-ironic-conductor python-ironicclient"
|
||||
|
||||
install_rpm_by_yum "openstack-ironic-api openstack-ironic-common openstack-ironic-conductor python-ironicclient"
|
||||
|
||||
write_install_log "install ironic-discoverd depend rpm"
|
||||
install_rpm_by_yum "python-flask"
|
||||
|
||||
write_install_log "install ironic-discoverd rpm"
|
||||
install_rpm_by_yum "openstack-ironic-discoverd python-ironic-discoverd"
|
||||
|
||||
install_rpm_by_daisy_yum "openstack-ironic-discoverd python-ironic-discoverd"
|
||||
|
||||
write_install_log "install daisy rpm"
|
||||
install_rpm_by_yum "daisy"
|
||||
|
||||
|
||||
write_install_log "install daisy dashboard rpm"
|
||||
install_rpm_by_yum "python-django-horizon-doc"
|
||||
install_rpm_by_daisy_yum "python-django-horizon-doc"
|
||||
install_rpm_by_yum "daisy-dashboard"
|
||||
|
||||
|
||||
write_install_log "install clustershell rpm"
|
||||
install_rpm_by_yum "clustershell"
|
||||
|
||||
if [ -f "/etc/zte-docker" ];then
|
||||
write_install_log "install pxe_docker_install rpm"
|
||||
install_rpm_by_yum pxe_docker_install
|
||||
else
|
||||
write_install_log "install pxe server rpm"
|
||||
install_rpm_by_yum pxe_server_install
|
||||
install_rpm_by_daisy_yum pxe_server_install
|
||||
fi
|
||||
|
||||
# 获取管理网ip地址,然后把数据库的daisy用户更新到配置文件中
|
||||
#get management network IP address, and then update the database of Daisy user to the configuration file
|
||||
get_public_ip
|
||||
if [ -z $public_ip ];then
|
||||
write_install_log "Error:default gateway is not set!!!"
|
||||
@ -86,7 +92,7 @@ function all_install
|
||||
update_section_config "$daisy_file" database connection "mysql://daisy:daisy@$public_ip/$db_name?charset=utf8"
|
||||
config_keystone_local_setting
|
||||
fi
|
||||
|
||||
|
||||
systemctl restart openstack-keystone.service
|
||||
[ "$?" -ne 0 ] && { write_install_log "Error:systemctl restart openstack-keystone.service failed"; exit 1; }
|
||||
systemctl restart httpd.service
|
||||
@ -97,19 +103,17 @@ function all_install
|
||||
[ "$?" -ne 0 ] && { write_install_log "Error:systemctl start daisy-registry.service failed"; exit 1; }
|
||||
systemctl start mariadb.service
|
||||
[ "$?" -ne 0 ] && { write_install_log "Error:systemctl start mariadb.service failed"; exit 1; }
|
||||
|
||||
|
||||
|
||||
systemctl enable openstack-keystone.service >> $install_logfile 2>&1
|
||||
systemctl enable httpd.service >> $install_logfile 2>&1
|
||||
systemctl enable daisy-api.service >> $install_logfile 2>&1
|
||||
systemctl enable daisy-registry.service >> $install_logfile 2>&1
|
||||
systemctl enable mariadb.service >> $install_logfile 2>&1
|
||||
|
||||
|
||||
mysql_cmd="mysql"
|
||||
local mariadb_result=`systemctl is-active mariadb.service`
|
||||
if [ $? -eq 0 ];then
|
||||
# 创建keystone数据库
|
||||
# creat keystone datebase
|
||||
local create_keystone_sql="create database IF NOT EXISTS $keystone_db_name default charset=utf8"
|
||||
write_install_log "create $keystone_db_name database in mariadb"
|
||||
echo ${create_keystone_sql} | ${mysql_cmd}
|
||||
@ -117,8 +121,8 @@ function all_install
|
||||
write_install_log "Error:create $keystone_db_name database failed..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 创建daisy数据库
|
||||
|
||||
# creat daisy datebase
|
||||
local create_db_sql="create database IF NOT EXISTS $db_name default charset=utf8"
|
||||
write_install_log "create $db_name database in mariadb"
|
||||
echo ${create_db_sql} | ${mysql_cmd}
|
||||
@ -126,8 +130,8 @@ function all_install
|
||||
write_install_log "Error:create $db_name database failed..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 创建ironic数据库
|
||||
|
||||
# creat ironic datebase
|
||||
local create_ironic_sql="create database IF NOT EXISTS $ironic_name default charset=utf8"
|
||||
write_install_log "create $ironic_name database in mariadb"
|
||||
echo ${create_ironic_sql} | ${mysql_cmd}
|
||||
@ -135,8 +139,8 @@ function all_install
|
||||
write_install_log "Error:create $ironic_name database failed..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 创建keystone用户
|
||||
|
||||
# create keystone user
|
||||
write_install_log "create keystone user in mariadb"
|
||||
echo "grant all privileges on *.* to 'keystone'@'localhost' identified by 'keystone'" | ${mysql_cmd}
|
||||
if [ $? -ne 0 ];then
|
||||
@ -144,15 +148,15 @@ function all_install
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 创建daisy用户
|
||||
# create daisy user
|
||||
write_install_log "create daisy user in mariadb"
|
||||
echo "grant all privileges on *.* to 'daisy'@'localhost' identified by 'daisy'" | ${mysql_cmd}
|
||||
if [ $? -ne 0 ];then
|
||||
write_install_log "Error:create daisy user failed..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 创建ironic用户
|
||||
|
||||
# create ironic user
|
||||
write_install_log "create ironic user in mariadb"
|
||||
echo "grant all privileges on ironic.* to 'ironic'@'localhost' identified by 'ironic'" | ${mysql_cmd}
|
||||
if [ $? -ne 0 ];then
|
||||
@ -160,46 +164,45 @@ function all_install
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 给keystone数据库赋予主机访问权限
|
||||
# give the host access to keystone database
|
||||
write_install_log "Give the host access to the keystone database"
|
||||
echo "grant all privileges on keystone.* to 'keystone'@'%' identified by 'keystone'"| ${mysql_cmd}
|
||||
if [ $? -ne 0 ];then
|
||||
write_install_log "Error:Give the host access to the keystone database failed..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 给daisy数据库赋予主机访问权限
|
||||
|
||||
# give the host access to daisy database
|
||||
write_install_log "Give the host access to the daisy database"
|
||||
echo "grant all privileges on daisy.* to 'daisy'@'%' identified by 'daisy'"| ${mysql_cmd}
|
||||
if [ $? -ne 0 ];then
|
||||
write_install_log "Error:Give the host access to the daisy database failed..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 给ironic数据库赋予主机访问权限
|
||||
|
||||
# give the host access to ironic database
|
||||
write_install_log "Give the host access to the ironic database"
|
||||
echo "grant all privileges on ironic.* to 'ironic'@'%' identified by 'ironic'"| ${mysql_cmd}
|
||||
if [ $? -ne 0 ];then
|
||||
write_install_log "Error:Give the host access to the ironic database failed..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
echo "flush privileges"| ${mysql_cmd}
|
||||
|
||||
else
|
||||
else
|
||||
write_install_log "Error:mariadb service is not active"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
#创建keystone数据库的表
|
||||
|
||||
#creat keystone datebase tables
|
||||
which keystone-manage >> $install_logfile 2>&1
|
||||
if [ "$?" == 0 ];then
|
||||
write_install_log "start keystone-manage db_sync..."
|
||||
write_install_log "start keystone-manage db_sync..."
|
||||
keystone-manage db_sync
|
||||
[ "$?" -ne 0 ] && { write_install_log "Error:keystone-manage db_sync command failed"; exit 1; }
|
||||
[ "$?" -ne 0 ] && { write_install_log "Error:keystone-manage db_sync command failed"; exit 1; }
|
||||
fi
|
||||
#创建horizon admin账户
|
||||
#creat horizon admin account
|
||||
export OS_SERVICE_TOKEN=$keystone_admin_token
|
||||
export OS_SERVICE_ENDPOINT=http://$public_ip:35357/v2.0
|
||||
keystone user-create --name=admin --pass=keystone >> $install_logfile 2>&1
|
||||
@ -220,67 +223,67 @@ function all_install
|
||||
fi
|
||||
keystone endpoint-create --service-id=$service_id --region=RegionOne --publicurl=http://$public_ip:5000/v2.0 --internalurl=http://$public_ip:5000/v2.0 --adminurl=http://$public_ip:35357/v2.0 >> $install_logfile 2>&1
|
||||
[ "$?" -ne 0 ] && { write_install_log "Error:keystone endpoint-create command failed"; exit 1; }
|
||||
#创建daisy数据库的表
|
||||
#creat daisy datebase tables
|
||||
which daisy-manage >> $install_logfile 2>&1
|
||||
if [ "$?" == 0 ];then
|
||||
write_install_log "start daisy-manage db_sync..."
|
||||
write_install_log "start daisy-manage db_sync..."
|
||||
daisy-manage db_sync
|
||||
[ "$?" -ne 0 ] && { write_install_log "Error:daisy-manage db_sync command failed"; exit 1; }
|
||||
[ "$?" -ne 0 ] && { write_install_log "Error:daisy-manage db_sync command failed"; exit 1; }
|
||||
fi
|
||||
|
||||
#增加rabbitmq相关的配置文件
|
||||
|
||||
#add rabbitmq related configuration
|
||||
config_rabbitmq_env
|
||||
config_rabbitmq_config
|
||||
|
||||
#配置ironic相关的配置项
|
||||
config_ironic "/etc/ironic/ironic.conf"
|
||||
config_rabbitmq_config
|
||||
|
||||
#Configure ironic related configuration items
|
||||
config_ironic "/etc/ironic/ironic.conf"
|
||||
config_ironic_discoverd "/etc/ironic-discoverd/discoverd.conf" "$public_ip"
|
||||
|
||||
#修改clustershell的配置文件
|
||||
|
||||
#modify clustershell configuration
|
||||
clustershell_conf="/etc/clustershell/clush.conf"
|
||||
sed -i "s/connect_timeout:[[:space:]]*.*/connect_timeout: 360/g" $clustershell_conf
|
||||
sed -i "s/command_timeout:[[:space:]]*.*/command_timeout: 3600/g" $clustershell_conf
|
||||
|
||||
#创建ironic数据库的表
|
||||
|
||||
#creat ironic datebase tables
|
||||
which ironic-dbsync >> $install_logfile 2>&1
|
||||
if [ "$?" == 0 ];then
|
||||
write_install_log "start ironic-dbsync ..."
|
||||
write_install_log "start ironic-dbsync ..."
|
||||
ironic-dbsync --config-file /etc/ironic/ironic.conf create_schema
|
||||
[ "$?" -ne 0 ] && { write_install_log "Error:ironic-dbsync --config-file /etc/ironic/ironic.conf create_schema failed"; exit 1; }
|
||||
[ "$?" -ne 0 ] && { write_install_log "Error:ironic-dbsync --config-file /etc/ironic/ironic.conf create_schema failed"; exit 1; }
|
||||
fi
|
||||
|
||||
|
||||
systemctl restart rabbitmq-server.service
|
||||
[ "$?" -ne 0 ] && { write_install_log "Error:systemctl restart rabbitmq-server.service failed"; exit 1; }
|
||||
|
||||
|
||||
systemctl restart openstack-keystone.service
|
||||
[ "$?" -ne 0 ] && { write_install_log "Error:systemctl restart rabbitmq-server.service failed"; exit 1; }
|
||||
|
||||
systemctl restart openstack-ironic-api.service
|
||||
|
||||
systemctl restart openstack-ironic-api.service
|
||||
[ "$?" -ne 0 ] && { write_install_log "Error:systemctl restart openstack-ironic-api.service failed"; exit 1; }
|
||||
systemctl restart openstack-ironic-conductor.service
|
||||
[ "$?" -ne 0 ] && { write_install_log "Error:systemctl restart openstack-ironic-conductor.service failed"; exit 1; }
|
||||
systemctl restart openstack-ironic-discoverd.service
|
||||
[ "$?" -ne 0 ] && { write_install_log "Error:systemctl restart openstack-ironic-discoverd.service failed"; exit 1; }
|
||||
|
||||
|
||||
systemctl start daisy-orchestration.service
|
||||
[ "$?" -ne 0 ] && { write_install_log "Error:systemctl start daisy-orchestration.service failed"; exit 1; }
|
||||
|
||||
|
||||
systemctl enable daisy-orchestration.service >> $install_logfile 2>&1
|
||||
systemctl enable openstack-ironic-api.service >> $install_logfile 2>&1
|
||||
systemctl enable openstack-ironic-conductor.service >> $install_logfile 2>&1
|
||||
systemctl enable openstack-ironic-discoverd.service >> $install_logfile 2>&1
|
||||
|
||||
#daisy初始化,创建组件、服务、角色以及网络平面
|
||||
|
||||
#init daisy
|
||||
daisy_init_func
|
||||
|
||||
|
||||
modify_sudoers /etc/sudoers requiretty
|
||||
|
||||
|
||||
daisyrc_admin "$public_ip"
|
||||
|
||||
|
||||
build_pxe_server "$public_ip" "$bind_port"
|
||||
|
||||
|
||||
config_get_node_info
|
||||
|
||||
|
||||
write_install_log "Daisy Install Successfull..."
|
||||
}
|
||||
_INSTALL_INTERFACE_FILE="install_interface.sh"
|
||||
|
Loading…
x
Reference in New Issue
Block a user