Deploy Openstack all-in-one Shell Script
Deploy Openstack all-in-one Shell Script
At present(2015/10), the RDO deploment method can only install VNC console defalut,
and there is no other way to config the configuration file to change to Spice like DevStack.
The following script shows how to deploy quickly.
#!/bin/bash
###############################################
# This shell script is used to deploy openstack
# in one node (a vm or a physical machine)
# which host OS is CentOS (CentOS 7) is
# recommended.
#
# Date: 2015/10/25
###############################################
# get the host ip address
# HOSTIP=`ifconfig | grep "inet " | grep -v "127.0.0.1" | awk '{print $2}'`
HOSTIP=`ifconfig | grep "inet " | grep -v "127.0.0.1" | cut -d: -f2 | awk '{print $1}'`
# update system and install openstack using packstack
sudo yum update -y &&
sudo yum install -y https://rdoproject.org/repos/rdo-release.rpm &&
sudo yum install -y openstack-packstack &&
packstack --allinone
if [[ $? == 0 ]];
then
echo -e "\033[32m ****** Install Openstack successfully ****** \033[0m "
systemctl stop openstack-nova-novncproxy.service
else
echo -e "\033[33m ****** Install Openstack failed ****** \033[0m "
sleep 3
exit
fi
sleep 5
# simplify the nova configuration file
NOVACONF=/etc/nova/nova.conf
if [ -f $NOVACONF ];
then
cp $NOVACONF $NOVACONF.bak &&
cat $NOVACONF.bak | grep -v '^#' | grep -v '^$' > $NOVACONF
fi
sleep 10
# disable vnc server
sed -i '/vnc/d' $NOVACONF && sed -i '2a vnc_enabled=False' $NOVACONF
sleep 5
# install spice proxy
sudo yum install spice-html5 -y &&
sudo yum install openstack-nova-spicehtml5proxy -y &&
sleep 5
# add spice configutation
sudo sed -i '/spice/d' /etc/nova/nova.conf
if [[ $? == 0 ]];
then
echo "[spice]" >> $NOVACONF
echo "enabled=True" >> $NOVACONF
echo "agent_enabled=true" >> $NOVACONF
echo "server_listen=0.0.0.0" >> $NOVACONF
echo "html5proxy_host=0.0.0.0" >> $NOVACONF
echo "html5proxy_port=6082" >> $NOVACONF
echo "html5proxy_base_url=http://$HOSTIP:6082/spice_auto.html" >> $NOVACONF
echo "keymap=en-us" >> $NOVACONF
fi
# open the spice port
iptables -I INPUT -p tcp -m multiport --dports 6082 -m comment --comment "Allow SPICE connections for console access " -j ACCEPT
sleep 5
# restart related services
service openstack-nova-compute restart &&
service httpd restart &&
systemctl enable openstack-nova-spicehtml5proxy &&
systemctl start openstack-nova-spicehtml5proxy.service
# print the result
if [[ $? == 0 ]];
then
echo -e "\033[32m ***************************************************** \033[0m"
echo -e "\033[32m ****** The OpenStack is deployed successfully******** \033[0m"
echo -e "\033[32m ***************************************************** \033[0m"
fi
Run the following scrip as root and get the spice client access addresss:
#!/bin/sh
virsh list | grep "instance" > virshlist.log
ps -ef | grep spice > spiceport.log
hostip=`ifconfig | grep "inet " | grep -v "127.0.0.1" | awk '{print $2}'`
echo "Instance name Access address"
echo "------------------------------------------------------------"
for i in `cat virshlist.log | awk {'print $2'}`
do
# echo $i
virsh dumpxml $i > $i.xml &&
instance_name=`grep "nova:name" $i.xml | cut -d ">" -f 2 | cut -d "<" -f 1` &&
spiceport=`grep $i spiceport.log | awk -F "port=" '{print $2}' | cut -d"," -f1` &&
echo "\033[32m $instance_name \t\t $hostip:$spiceport \033[0m"
done
if downloading from fedora repo is too slowly or some problem like "Cannot retrieve repository"
please change the/etc/yum.repos.d/rdo-release.repo
as following:
[openstack]
name=cloud
baseurl=http://mirrors.sohu.com/centos/7/cloud/x86_64/openstack-liberty/
gpgcheck=0
enabled=1
Deploy Openstack all-in-one Shell Script的更多相关文章
- 这些年我们一起搞过的持续集成~Jenkins+Perl and Shell script
这些年我们一起搞过的持续集成~Jenkins+Perl and Shell script ##转载注明出处:http://www.cnblogs.com/wade-xu/p/4378224.html ...
- shell及脚本4——shell script
一.格式 1.1 开头 必须以 "# !/bin/bash" 开头,告诉系统这是一个bash shell脚本.注意#与!中间有空格. 二.语法 2.1 数值运算 可以用decla ...
- shell script
一.shell script的编写与执行 1.shell script 的编写中还需要用到下面的注意事项: a.命令的执行是从上到下,从左到右地分析与执行 b.命令.参数间的多个空白都会被忽略掉 c. ...
- (copy) Shell Script to Check Linux System Health
source: http://linoxide.com/linux-shell-script/shell-script-check-linux-system-health/ This article ...
- shell script练习
执行脚本的几种方式: 1. sh a.sh 或者 bash a.sh 调用的是 /bin/bash 进程执行的,所以脚本不需要执行权限. 2. 直接使用绝对路径执行, /home/script/a ...
- CentOS Linux下一个tomcat起停,查看日志的shell script
CentOS 的tomcat安装目录:/usr/local/tomcat vi MyTomcatUitl.sh 创建文件chmod u+x MyTomcatUtil.sh 赋执行 ...
- Shell script for logging cpu and memory usage of a Linux process
Shell script for logging cpu and memory usage of a Linux process http://www.unix.com/shell-programmi ...
- shell script入门
从程序员的角度来看, Shell本身是一种用C语言编写的程序,从用户的角度来看,Shell是用户与Linux操作系统沟通的桥梁.用户既可以输入命令执行,又可以利用 Shell脚本编程,完成更加复杂的操 ...
- shell script 的追踪与 debug
shell script 的追踪与 debug scripts 在运行之前,最怕的就是出现语法错误的问题了!那么我们如何 debug 呢?有没有办法不需要透过直接运行该 scripts 就可以来判断是 ...
随机推荐
- Bracket Sequences Concatenation Problem CodeForces - 990C(括号匹配水题)
明确一下 一个字符串有x左括号不匹配 和 另一个字符串有x个右括号不匹配 这俩是一定能够匹配的 脑子有点迷 emm... 所以统计就好了 统计x个左括号的有几个,x个右括号的有几个 然后 乘一 ...
- Power Strings POJ - 2406(next水的一发 || 后缀数组)
后缀数组专题的 emm.. 就next 循环节../ 有后缀数组也可以做 从小到大枚举长度i,如果长度i的子串刚好是重复了len/i次,应该满足len % i == 0和rank[0] - rank[ ...
- c++11 右尖括号>改进
c++11 右尖括号>改进 #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <string> # ...
- 【题解】CF#896 D-Nephren Runs a Cinema
容易发现这些 vip 用户并没什么用,所以考虑枚举手持50元与100元的人共有多少个.设手持50元的人 \(a\) 个,手持100元的人 \(a - k\) 个,那么一共是 \(2*a - k\) 个 ...
- php的数组转为对象
有时候数组要转为对象操作,用对象的指向操作符,有两种方法 方法一: $arr=['a'=>10,'b'=>100,'c'=>'Hello']; $obj=(Object)$arr; ...
- ACM比赛_注意
ACM比赛_注意: 比赛前: 1.前一天早一点睡觉 2.避免参加激烈的活动,以免比赛时精力不足; 3.少喝水,并提前上厕所; 4.把账号,密码都准备好,放在txt中 5.提前创建多个程序(etc.10 ...
- C/C++ 多继承{虚基类,虚继承,构造顺序,析构顺序}
C/C++:一个基类继承和多个基类继承的区别 1.对多个基类继承会出现类之间嵌套时出现的同名问题,如果同名变量或者函数出现不在同一层次,则底层派生隐藏外层比如继承基类的同名变量和函数,不会出现二义性, ...
- BZOJ1053:反素数(数学)
题目链接 对于任意的正整数\(x\),记其约数的个数为\(g(x)\).现在定义反素数:对于\(0<i<x\),都有\(g(x)>g(i)\),那么就称x为反素数. 现在给定一个数N ...
- csu1377Putter && HOJ12816
链接:(csu)http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1377 (HOJ)http://49.123.82.55/online/?actio ...
- 四、Linux学习之文件处理命令
1.建立目录:mkdir 格式:mkdir –p [目录名] -p 递归创建目录 注意事项: 如果是创建单个目录直接mkdir [目录名就可以] 如果是创建一个目录下的目录也就是递归创建目录请 ...