博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
openstack_juno_allinone_ubuntu的脚本文件
阅读量:4179 次
发布时间:2019-05-26

本文共 27930 字,大约阅读时间需要 93 分钟。

下列脚本文件皆从ubuntu发布的关于openstack的镜像中提取,便于以后的查询和使用。

(1)安装openstack的6个组件

allinoneinstall-ubuntu.sh(shell部分在页面显示有问题,可以左上脚的view plain查看):

#!/bin/shlocal_ip=`ifconfig eth0 | grep Bcast | awk {'print $2'} | awk -F ":" {'print $2'}`netmask=`ifconfig eth0 | grep Mask | awk -F "Mask:" {'print $2'}`gateway=""if [ -f /var/lib/dhcp/dhclient.eth0.leases ];then    gateway=`cat /var/lib/dhcp/dhclient.eth0.leases | grep routers | awk '{print $3}' | awk -F ";" '{print $1}'`else    gateway=`cat /etc/network/interfaces | grep gateway | awk {'print $2'}`figateway=`echo $gateway |awk -F " " '{print $NF}'`home_path=/opt/openstackos_VENDOR=""############################get OS#############################function get_OS(){LOG "get OS"if [[ -x $(which lsb_release 2>/dev/null) ]]; then    os_VENDOR=$(lsb_release -i -s)fi}##########################add repo#############################function add_repo(){LOG "add repo"mv /etc/apt/sources.list /etc/apt/sources.list.bakecho "deb file:/opt/openstack openstack/" >> /etc/apt/sources.listapt-get update#apt-get upgrade --force-yes -y}######################## config network ########################function init_network(){LOG "begin init network "/bin/bash $home_path/restore_networking.shinstall_package openvswitch-common openvswitch-switchservice openvswitch-switch restartsleep 2ovs-vsctl add-br br-intovs-vsctl add-br br-eth1ovs-vsctl add-br br-exovs-vsctl add-port br-ex eth0cat >/etc/network/interfaces <
/root/novarcecho "export OS_USERNAME=admin" >> /root/novarcecho "export OS_PASSWORD=openstack" >> /root/novarcecho "export OPENSTACK_PASSWD=openstack" >> /root/novarc#echo "export SERVICE_PASSWORD=$password" >> /root/novarc#echo "export RABBIT_PASSWORD=$password" >> /root/novarc#echo "export OS_SERVICE_TOKEN=$OS_SERVICE_TOKEN" >> /root/novarc#echo "export OS_SERVICE_ENDPOINT=$OS_SERVICE_ENDPOINT" >> /root/novarcecho "export OS_AUTH_URL=http://$local_ip:5000/v2.0" >> /root/novarcecho "source /root/novarc" >> /root/.bashrcsource /root/novarc}######################## install rabbitmq ########################function install_rabbitmq(){install_package rabbitmq-serverservice rabbitmq-server restartsleep 3rabbitmqctl change_password guest $OPENSTACK_PASSWDsleep 3}##################################################### modify config ##########################function update_config(){cd $home_path/etcfor i in `find ./`;do sed -i "s/openstack-ip/$local_ip/g" $i;donefor i in `find ./`;do sed -i "s/openstack-passwd/$OPENSTACK_PASSWD/g" $i;done}######################### install keystone ##########################function install_keystone(){keystone_packages="keystone python-keystoneclient"install_package $keystone_packagescp -r $home_path/etc/keystone/* /etc/keystone/service keystone restartrm /var/lib/keystone/keystone.dbsu -s /bin/sh -c "keystone-manage db_sync" keystone#keystone-manage pki_setup --keystone-user keystone --keystone-group keystonesleep 3chmod +x $home_path/etc/keystone_basic.shchmod +x $home_path/etc/keystone_endpoints_basic.shsh $home_path/etc/keystone_basic.shsh $home_path/etc/keystone_endpoints_basic.shsleep 3}########################## config keystone ##########################function config_keystone(){cp -r etc/keystone/* /etc/keystone/if [ "Ubuntu" = $os_VENDOR ]; then service keystone restart keystone-manage db_sync sleep 2 chmod +x etc/keystone_basic.sh chmod +x etc/keystone_endpoints_basic.sh sh etc/keystone_basic.sh sh etc/keystone_endpoints_basic.sh sleep 2fi}########################### install glance ##########################function install_glance(){keystone_packages="glance python-glanceclient"install_package $keystone_packagessleep 2cp -r $home_path/etc/glance/* /etc/glance/rm /var/lib/glance/glance.sqlitesu -s /bin/sh -c "glance-manage db_sync" glanceservice glance-api restartservice glance-registry restart##############################}############################ install nova ###########################function install_nova(){nova_package="nova-api nova-scheduler nova-cert nova-conductor nova-consoleauth nova-novncproxy nova-compute python-novaclient"install_package $nova_packagesleep 3cp -r $home_path/etc/nova/* /etc/nova/rm /var/lib/nova/nova.sqlitesu -s /bin/sh -c "nova-manage db sync" nova#dpkg-statoverride --update --add root root 0644 /boot/vmlinuz-$(uname -r)num=`egrep -c '(vmx|svm)' /proc/cpuinfo`if [ $num -eq 0 ];then sed -i "s/virt_type=.*/virt_type=qemu/g" /etc/nova/nova-compute.conffi#echo 'kvm_intel' >> /etc/modulesfor svc in api conductor cert consoleauth conductor scheduler novncproxy compute; do service nova-$svc restart; done;##############################}############################# config ovs ############################function config_ovs(){service openvswitch-switch restartsleep 2ovs-vsctl add-br br-intovs-vsctl add-br br-eth1ovs-vsctl add-br br-ex}########################## install neutron ##########################function install_neutron(){LOG "begin install neutron"neutron_packages="neutron-server python-neutronclient neutron-plugin-ml2 neutron-plugin-openvswitch-agent neutron-l3-agent neutron-dhcp-agent ipset"install_package $neutron_packagesnovatenantid=`keystone tenant-list | awk '/ nova / { print $2 }'`sed -i "s/novatenantid/$novatenantid/g" $home_path/etc/neutron/neutron.confcp -r $home_path/etc/neutron/* /etc/neutronrm /var/lib/neutron/neutron.sqlitesu -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf \ --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade juno" neutron#mkdir -p /var/lock/neutron#chown neutron:neutron /var/lock/neutron#sed -i 's/NEUTRON_PLUGIN_CONF/#NEUTRON_PLUGIN_CONF/' /etc/sysconfig/neutron#echo NEUTRON_PLUGIN_CONF=\"/etc/neutron/plugins/ml2/ml2_conf.ini\" >> /etc/sysconfig/neutronsleep 3LOG "service openstack-neutron restart"service nova-api restartservice nova-scheduler restartservice nova-conductor restartservice neutron-server restartservice neutron-plugin-openvswitch-agent restartservice neutron-l3-agent restartservice neutron-dhcp-agent restartservice neutron-metadata-agent restartLOG "end install neutron"##########################}########################### install cinder ##########################function install_cinder(){cinder_packages="cinder-api cinder-scheduler python-cinderclient lvm2 cinder-volume"install_package $cinder_packagescp -r $home_path/etc/cinder/* /etc/cinderrm /var/lib/cinder/cinder.sqlitesu -s /bin/sh -c "cinder-manage db sync" cindervgremove cinder-volumesdd if=/dev/zero of=/var/cinder-volumes bs=1 count=0 seek=10Glosetup /dev/loop2 /var/cinder-volumespvcreate /dev/loop2vgcreate cinder-volumes /dev/loop2echo "losetup /dev/loop2 /var/cinder-volumes" >>/etc/init.d/rc.localecho "vgchange -a y cinder-volumes" >>/etc/init.d/rc.localecho "service cinder-volume restart" >>/etc/init.d/rc.localservice cinder-scheduler restartservice cinder-api restartservice cinder-volume restartservice tgt restart############################}########################### install mongodb #########################function install_mongodb(){mongodb_packages="mongodb-server"install_package $mongodb_packagessed -i "s/127.0.0.1/$local_ip/g" /etc/mongodb.confchown -R mongodb:mongodb /var/lib/mongodb/service mongodb restartsleep 3chown -R mongodb:mongodb /var/lib/mongodb/sleep 2mongo --host $local_ip $home_path/etc/config_mongodb.jsmongo --host $local_ip --eval 'db = db.getSiblingDB("ceilometer");db.addUser({user: "ceilometer", pwd: "openstack", roles: [ "readWrite", "dbAdmin" ]})'mongo_ret=$?retry=0while [ $mongo_ret -eq 1 -a $retry -le 5 ];do sleep 2 mongo --host $local_ip --eval ' db = db.getSiblingDB("ceilometer"); db.addUser({user: "ceilometer", pwd: "openstack", roles: [ "readWrite", "dbAdmin" ]})' mongo_ret=$? retry=`expr $retry + 1`done;#mongo --host $local_ip $home_path/etc/config_mongodb.jssleep 3########################}######################### install ceilometer ########################function install_ceilometer(){#TODO is this bug?patch_packages="python-bson python-pymongo"install_package $patch_packagesceilometer_packages="ceilometer-api ceilometer-collector ceilometer-agent-central ceilometer-agent-notification ceilometer-alarm-evaluator ceilometer-alarm-notifier python-ceilometerclient ceilometer-agent-compute"install_package $ceilometer_packagessleep 3cp -r $home_path/etc/ceilometer/* /etc/ceilometer/su -s /bin/sh -c "ceilometer-dbsync" ceilometersleep 2rm /var/lib/ceilometer/ceilometer.sqliteservice ceilometer-agent-central restartservice ceilometer-agent-notification restartservice ceilometer-api restartservice ceilometer-collector restartservice ceilometer-alarm-evaluator restartservice ceilometer-alarm-notifier restartservice nova-compute restartservice ceilometer-agent-compute restart############################}########################### install heat ############################function install_heat(){heat_packages="heat-api heat-api-cfn heat-engine python-heatclient"install_package $heat_packagescp -r $home_path/etc/heat/* /etc/heat/rm /var/lib/heat/heat.sqlitesu -s /bin/sh -c "heat-manage db_sync" heatservice heat-api restartservice heat-api-cfn restartservice heat-engine restart}########################## install horizon ##########################function install_horizon(){horizon_packages="openstack-dashboard apache2 libapache2-mod-wsgi memcached python-memcache"install_package $horizon_packagesapt-get remove --purge openstack-dashboard-ubuntu-theme -ycp $home_path/etc/local_settings.py /etc/openstack-dashboard/#/usr/share/openstack-dashboard/manage.py syncdb#mkdir -p /var/lib/dash/.blackholeservice apache2 restartservice memcached restart}#TODO########################## install trove ##########################function install_trove(){trove_packages="python-trove python-troveclient python-glanceclient trove-common trove-api trove-taskmanager"install_package $trove_packagescp -r $home_path/etc/trove/* /etc/trove/su -s /bin/sh -c "trove-manage db_sync" trovesu -s /bin/sh -c "trove-manage datastore_update mysql ''" troveservice trove-api restartservice trove-taskmanager restartservice trove-conductor restart}########################### install patch ###########################function install_patch(){neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade headsed -i 's/\/etc\/cinder\/rootwrap.conf/\/etc\/cinder\/rootwrap.conf \*/' /etc/sudoers.d/cinder_sudoerssed -i 's/\[DEFAULT\]/&\napi_paste_config=\/etc\/ceilometer\/api_paste.ini/g' /etc/ceilometer/ceilometer.confmongo --host $local_ip --eval 'db = db.getSiblingDB("ceilometer");db.addUser({user: "ceilometer", pwd: "root", roles: [ "readWrite", "dbAdmin" ]})'}function restart_nova(){for svc in api conductor cert consoleauth conductor scheduler novncproxy compute; do service nova-$svc restart; done;}function restart_neutron(){service neutron-plugin-openvswitch-agent restartservice neutron-server restartservice neutron-plugin-openvswitch-agent restartservice neutron-l3-agent restartservice neutron-dhcp-agent restartservice neutron-metadata-agent restart}function restart_cinder(){service tgt restartservice cinder-api restartservice cinder-scheduler restartservice cinder-volume restart}function restart_glance(){service glance-api restartservice glance-registry restart}function restart_ceilometer(){service ceilometer-agent-central restartservice ceilometer-agent-notification restartservice ceilometer-api restartservice ceilometer-collector restartservice ceilometer-alarm-evaluator restartservice ceilometer-alarm-notifier restartservice ceilometer-agent-compute restart}function restart_heat(){service heat-api restartservice heat-api-cfn restartservice heat-engine restart}function restart_service(){service keystone restartrestart_novarestart_neutronrestart_cinderrestart_glancerestart_ceilometerrestart_heatsleep 3}function check(){LOG "check begin"source /root/novarccheck_novacheck_cindercheck_neutroncheck_glancecheck_keystonecheck_heatcheck_ceilometerLOG "check end,openstack is OK"}function service_check(){logfile="/opt/openstack/check.log"servicename=$1servicenum=$2if [ $servicename != "nova" -a $servicename != "cinder" ] ;then num=`ps -ef|grep $servicename- | grep -v grep | wc -l` if [ $num -ge $servicenum ]; then echo "$servicename service is OK" >> $logfile else echo "$servicename is NOK" >> $logfile exit 1 fielse num=`$servicename service-list | grep up | wc -l` if [ $num -eq $servicenum ]; then echo "$servicename service is OK" >> $logfile else name=`$servicename service-list | grep down | awk -F "|" {'print $2'}` echo "$name is NOK" >> $logfile exit 1 fifi}function list(){logfile="/opt/openstack/check.log"name=$1listnum=$2if [ $name = "neutron" ];then num=`$name net-list | wc -l` if [ $num -eq $listnum ];then echo "$name net-list is OK" >> $logfile else echo "$name net-list is NOK" >> $logfile exit 1 fielif [ $name = "glance" ];then num=`$name image-list | wc -l` if [ $num -eq $listnum ];then echo "$name image-list is OK" >> $logfile else echo "$name image-list is NOK" >> $logfile exit 1 fielif [ $name = "ceilometer" ];then num=`$name alarm-list | wc -l` if [ $num -eq $listnum ];then echo "$name alarm-list is OK" >> $logfile else echo "$name alarm-list is NOK" >> $logfile exit 1 fielif [ $name = "heat" ];then num=`$name stack-list | wc -l` if [ $num -eq $listnum ];then echo "$name stack-list is OK" >> $logfile else echo "$name stack-list is NOK" >> $logfile exit 1 fielif [ $name = "keystone" ];then num=`$name user-list | wc -l` if [ $num -eq $listnum ];then echo "$name user-list is OK" >> $logfile else echo "$name user-list is NOK" >> $logfile exit 1 fielse num=`$name list | wc -l` if [ $num -eq $listnum ];then echo "$name list is OK" >> $logfile else echo "$name list is NOK" >> $logfile exit 1 fifi}function check_nova(){logfile="/opt/openstack/check.log"LOG "check nova"echo "nova check begin" >> $logfiletype=`cat /etc/nova/nova-compute.conf | grep virt_type | awk -F "=" {'print $2'}`cpu=`egrep -c '(vmx|svm)' /proc/cpuinfo`if [[ $type = "kvm" ]] && [[ $cpu -gt 0 ]];then echo "virt_tpyt is OK" >> $logfileelif [[ $type = "qemu" ]] && [[ $cpu -eq 0 ]];then echo "virt_tpyt is OK" >> $logfileelse echo "virt_tpyt is NOK" >> $logfile exit 1fiservice_check nova 5result=`echo $?`if [ $result -ne 0 ]; then exit $resultfilist nova 4result=`echo $?`if [ $result -ne 0 ]; then exit $resultfiecho "nova is OK" >> /opt/openstack/check.logLOG "nova is OK"}function check_cinder(){logfile="/opt/openstack/check.log"LOG "check cinder"echo "cinder check begin" >> $logfilevg=`vgs | grep cinder-volumes | wc -l`if [ $vg -eq 1 ]; then echo "vg is OK" >> $logfileelse echo "vg is NOK" >> $logfile exit 1fiservice_check cinder 2result=`echo $?`if [ $result -ne 0 ]; then exit $resultfilist cinder 4result=`echo $?`if [ $result -ne 0 ]; then exit $resultficinder create 1sleep 1num=`cinder list | grep available | wc -l`if [ $num -eq 1 ]; then echo "create volume is OK" >> $logfilefiecho "cinder is OK" >> $logfileLOG "cinder is OK"}function check_glance(){logfile="/opt/openstack/check.log"LOG "check glance"echo "glance check begin" >> $logfileservice_check glance 7result=`echo $?`if [ $result -ne 0 ]; then exit $resultfilist glance 4result=`echo $?`if [ $result -ne 0 ]; then exit $resultfi}function check_neutron(){logfile="/opt/openstack/check.log"LOG "check neutron"echo "neutron check begin" >> $logfile#service_check neutron 11#result=`echo $?`#if [ $result -ne 0 ]; then# exit $result#filist neutron 1result=`echo $?`if [ $result -ne 0 ]; then exit $resultfi}function check_keystone(){logfile="/opt/openstack/check.log"LOG "check keystone"echo "keystone check begin" >> $logfileservice_check keystone 1result=`echo $?`if [ $result -ne 0 ]; then exit $resultfilist keystone 12result=`echo $?`if [ $result -ne 0 ]; then exit $resultfi}function check_ceilometer(){logfile="/opt/openstack/check.log"LOG "check ceilometer"echo "ceilometer check begin" >> $logfileservice_check ceilometer 6result=`echo $?`if [ $result -ne 0 ]; then exit $resultfilist ceilometer 4result=`echo $?`if [ $result -ne 0 ]; then exit $resultfi}function check_heat(){logfile="/opt/openstack/check.log"LOG "check heat"echo "heat check begin" >> $logfileservice_check heat 3result=`echo $?`if [ $result -ne 0 ]; then exit $resultfilist heat 4result=`echo $?`if [ $result -ne 0 ]; then exit $resultfi}function LOG(){echo "`date -u +'%Y-%m-%d %T'`: $@"echo "`date -u +'%Y-%m-%d %T.%N'`: $@" >> /var/log/installallinone.log}function main(){add_repoinit_envinit_networkupdate_configinstall_dbinstall_rabbitmqinstall_keystoneinstall_glanceinstall_cinderinstall_neutroninstall_novainstall_mongodbinstall_ceilometerinstall_heatinstall_horizon#install_patchrestart_servicecheck}main $@

(2)设置openstack数据库权限

config-DB-mysql.sh:

mysql -uroot -popenstack-passwd <

(3)openstack的keystone配置

keystone_basic.sh:
#!/bin/sh## Keystone basic configuration # Mainly inspired by https://github.com/openstack/keystone/blob/master/tools/sample_data.sh# Modified by Bilel Msekni / Institut Telecom## Support: openstack@lists.launchpad.net# License: Apache Software License (ASL) 2.0#HOST_IP=openstack-ipADMIN_PASSWORD=openstack-passwdSERVICE_PASSWORD=openstack-passwdexport OS_SERVICE_TOKEN=2012export OS_SERVICE_ENDPOINT="http://${HOST_IP}:35357/v2.0"# Tenantskeystone tenant-create --name adminkeystone tenant-create --name service# Userskeystone user-create --name admin --pass "$ADMIN_PASSWORD" --email admin@domain.com# Roleskeystone role-create --name adminkeystone role-create --name _member_keystone role-create --name KeystoneAdminkeystone role-create --name KeystoneServiceAdminkeystone role-create --name heat_stack_userkeystone role-create --name heat_stack_owner# Add Roles to Users in Tenantskeystone user-role-add --user admin --role admin --tenant adminkeystone user-role-add --user admin --role _member_ --tenant adminkeystone user-role-add --user admin --role KeystoneAdmin --tenant adminkeystone user-role-add --user admin --role KeystoneServiceAdmin --tenant admin# The Member role is used by Horizon and Swift# Configure service users/roleskeystone user-create --name nova --pass $SERVICE_PASSWORD --email nova@domain.comkeystone user-role-add --tenant service --user nova --role adminkeystone user-create --name glance --pass "$SERVICE_PASSWORD"  --email glance@domain.comkeystone user-role-add --tenant service --user glance --role adminkeystone user-create --name neutron --pass "$SERVICE_PASSWORD"  --email quantum@domain.comkeystone user-role-add --tenant service --user neutron --role adminkeystone user-create --name cinder --pass "$SERVICE_PASSWORD"  --email cinder@domain.comkeystone user-role-add --tenant service --user cinder --role adminkeystone user-create --name ceilometer --pass "$SERVICE_PASSWORD" --email ceilometer@domain.comkeystone user-role-add --tenant service --user ceilometer --role adminkeystone user-create --name heat --pass "$SERVICE_PASSWORD"  --email heat@domain.comkeystone user-role-add --tenant service --user heat --role adminkeystone user-create --name swift --pass "$SERVICE_PASSWORD" --email swift@domain.comkeystone user-role-add --tenant service --user swift --role admin
keystone_endpoints_basic.sh:
#!/bin/sh## Keystone basic Endpoints# Mainly inspired by https://github.com/openstack/keystone/blob/master/tools/sample_data.sh# Modified by Bilel Msekni / Institut Telecom## Support: openstack@lists.launchpad.net# License: Apache Software License (ASL) 2.0## Host addressHOST_IP=openstack-ipEXT_HOST_IP=openstack-ip# Mysql definitionsMYSQL_USER=keystoneMYSQL_DATABASE=keystoneMYSQL_HOST=openstack-ipMYSQL_PASSWORD=openstack-passwd# Keystone definitionsKEYSTONE_REGION=RegionOneexport SERVICE_TOKEN=2012export SERVICE_ENDPOINT="http://openstack-ip:35357/v2.0"while getopts "u:D:p:m:K:R:E:T:vh" opt; do  case $opt in    u)      MYSQL_USER=$OPTARG      ;;    D)      MYSQL_DATABASE=$OPTARG      ;;    p)      MYSQL_PASSWORD=$OPTARG      ;;    m)      MYSQL_HOST=$OPTARG      ;;    K)      MASTER=$OPTARG      ;;    R)      KEYSTONE_REGION=$OPTARG      ;;    E)      export SERVICE_ENDPOINT=$OPTARG      ;;    T)      export SERVICE_TOKEN=$OPTARG      ;;    v)      set -x      ;;    h)      cat <
&2 exit 1 ;; :) echo "Option -$OPTARG requires an argument" >&2 exit 1 ;; esacdone if [ -z "$KEYSTONE_REGION" ]; then echo "Keystone region not set. Please set with -R option or set KEYSTONE_REGION variable." >&2 missing_args="true"fiif [ -z "$SERVICE_TOKEN" ]; then echo "Keystone service token not set. Please set with -T option or set SERVICE_TOKEN variable." >&2 missing_args="true"fiif [ -z "$SERVICE_ENDPOINT" ]; then echo "Keystone service endpoint not set. Please set with -E option or set SERVICE_ENDPOINT variable." >&2 missing_args="true"fiif [ -z "$MYSQL_PASSWORD" ]; then echo "MYSQL password not set. Please set with -p option or set MYSQL_PASSWORD variable." >&2 missing_args="true"fiif [ -n "$missing_args" ]; then exit 1fi keystone service-create --name nova --type compute --description 'OpenStack Compute Service'keystone service-create --name cinder --type volume --description 'OpenStack Volume Service'keystone service-create --name cinder --type volumev2 --description 'OpenStack Volume Service V2'keystone service-create --name glance --type image --description 'OpenStack Image Service'keystone service-create --name keystone --type identity --description 'OpenStack Identity Service'keystone service-create --name ec2 --type ec2 --description 'OpenStack EC2 service'keystone service-create --name neutron --type network --description 'OpenStack Networking service'keystone service-create --name ceilometer --type metering --description 'OpenStack Metering service'keystone service-create --name heat-cfn --type cloudformation --description 'Heat CloudFormation API'keystone service-create --name heat --type orchestration --description 'Heat Orchestration API'keystone service-create --name swift --type object-store --description 'Swift Object-Store Service'create_endpoint () { case $1 in compute) keystone endpoint-create --region $KEYSTONE_REGION --service-id $2 --publicurl 'http://'"openstack-ip"':8774/v2/$(tenant_id)s' --adminurl 'http://'"openstack-ip"':8774/v2/$(tenant_id)s' --internalurl 'http://'"openstack-ip"':8774/v2/$(tenant_id)s' ;; volume) keystone endpoint-create --region $KEYSTONE_REGION --service-id $2 --publicurl 'http://'"openstack-ip"':8776/v1/$(tenant_id)s' --adminurl 'http://'"openstack-ip"':8776/v1/$(tenant_id)s' --internalurl 'http://'"openstack-ip"':8776/v1/$(tenant_id)s' ;; volumev2) keystone endpoint-create --region $KEYSTONE_REGION --service-id $2 --publicurl 'http://'"openstack-ip"':8776/v2/$(tenant_id)s' --adminurl 'http://'"openstack-ip"':8776/v2/$(tenant_id)s' --internalurl 'http://'"openstack-ip"':8776/v2/$(tenant_id)s' ;; image) keystone endpoint-create --region $KEYSTONE_REGION --service-id $2 --publicurl 'http://'"openstack-ip"':9292/' --adminurl 'http://'"openstack-ip"':9292/' --internalurl 'http://'"openstack-ip"':9292/' ;; identity) keystone endpoint-create --region $KEYSTONE_REGION --service-id $2 --publicurl 'http://'"openstack-ip"':5000/v2.0' --adminurl 'http://'"openstack-ip"':35357/v2.0' --internalurl 'http://'"openstack-ip"':5000/v2.0' ;; ec2) keystone endpoint-create --region $KEYSTONE_REGION --service-id $2 --publicurl 'http://'"openstack-ip"':8773/services/Cloud' --adminurl 'http://'"openstack-ip"':8773/services/Admin' --internalurl 'http://'"openstack-ip"':8773/services/Cloud' ;; network) keystone endpoint-create --region $KEYSTONE_REGION --service-id $2 --publicurl 'http://'"openstack-ip"':9696/' --adminurl 'http://'"openstack-ip"':9696/' --internalurl 'http://'"openstack-ip"':9696/' ;; metering) keystone endpoint-create --region $KEYSTONE_REGION --service-id $2 --publicurl 'http://'"openstack-ip"':8777/' --adminurl 'http://'"openstack-ip"':8777/' --internalurl 'http://'"openstack-ip"':8777/' ;; cloudformation) keystone endpoint-create --region $KEYSTONE_REGION --service-id $2 --publicurl 'http://'"openstack-ip"':8000/v1' --adminurl 'http://'"openstack-ip"':8000/v1' --internalurl 'http://'"openstack-ip"':8000/v1' ;; orchestration) keystone endpoint-create --region $KEYSTONE_REGION --service-id $2 --publicurl 'http://'"openstack-ip"':8004/v1/$(tenant_id)s' --adminurl 'http://'"openstack-ip"':8004/v1/$(tenant_id)s' --internalurl 'http://'"openstack-ip"':8004/v1/$(tenant_id)s' ;; object-store) keystone endpoint-create --region $KEYSTONE_REGION --service-id $2 --publicurl 'http://'"openstack-ip"':8080/v1/AUTH_$(tenant_id)s' --adminurl 'http://'"openstack-ip"':8080' --internalurl 'http://'"openstack-ip"':8080/v1/AUTH_$(tenant_id)s' ;; esac}for i in compute volume volumev2 image identity ec2 network metering cloudformation orchestration object-store; do id=`mysql -h "$MYSQL_HOST" -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE" -ss -e "SELECT id FROM service WHERE type='"$i"';"` || exit 1 create_endpoint $i $iddone

(4)openstack创建虚拟机

createvm.sh:
#!/bin/shfloatingcidr=$1netname=testnetsource ~/novarc#glanceglance image-create --name=cirros --public --container-format=bare --disk-format=qcow2 < ./cirros-0.3.1-x86_64-disk.imgsleep 2status=`glance image-list | grep cirros | awk -F "|" {'print $7'} | awk {'print $1'}`while [ $status != "active" ]; do   sleep 1   status=`glance image-list | grep cirros | awk -F "|" {'print $7'} | awk {'print $1'}`doneimageid=`glance image-list | grep cirros | awk -F "|" {'print $2'} | awk {'print $1'}`#echo "image $status"#flavorflavor=`nova flavor-list | grep tiny | awk -F "|" {'print $2'} | awk {'print $1'}`#echo "flavor $flavor"#neutronneutron net-create $netnameneutron subnet-create --name fixedsubnet $netname 10.10.0.0/24sleep 2netid=`neutron net-list | grep $netname | awk -F "|" {'print $2'} | awk {'print $1'}`#echo "$netid"fixsubnetid=`neutron subnet-list | grep fixedsubnet | awk -F "|" {'print $2'} | awk {'print $1'}`#create routerneutron router-create testrouterrouteid=`neutron router-list | grep testroute | awk -F "|" {'print $2'} | awk {'print $1'}`neutron router-interface-add $routeid $fixsubnetidneutron net-create floatingnet --router:external=true#neutron net-create floatingnet --router:external=true --provider:network_type=vlan --provider:physical_network=physnet --provider:segmentation_id=200neutron subnet-create --name floatingsubnet floatingnet $floatingcidr/24floatingnetid=`neutron net-list | grep floatingnet | awk -F "|" {'print $2'} | awk {'print $1'}`neutron router-gateway-set $routeid $floatingnetid#neutron security-group-rule-create  --direction  ingress --protocol icmp $floatingnetid --remote-ip-prefix 0.0.0.0/0#neutron security-group-rule-create  --direction  ingress --protocol tcp $floatingnetid --remote-ip-prefix 0.0.0.0/0#create vmnova boot --flavor $flavor --image cirros --nic net-id=$netid testvm#sleep 3#status=`nova list | grep testvm | awk -F "|" {'print $4'} | awk {'print $1'}`#echo "$status"#while [ $status != "ACTIVE" ]; do#  if [ $status = "ERROR" ]; then#     echo "vm is $status,please check it."#  else#     sleep 1#     status=`nova list | grep name | awk -F "|" {'print $4'}`#  fi#done#modify tempest.conf#sed -i "s/cirrosimageid/$imageid/g" tempest.conf#sed -i "s/fixednetname/$netname/g" tempest.conf#sed -i "s/floatingnetid/$floatingnetid/g" tempest.conf#sed -i "s/floatingcidr/$floatingcidr/g" tempest.conf#sed -i "s/routeid/$routeid/g" tempest.conf

转载地址:http://sylai.baihongyu.com/

你可能感兴趣的文章
Linux的常用命令(二)
查看>>
第六篇: 分布式配置中心(Greenwich版本)
查看>>
SpringBoot | 配置logback-spring.xml
查看>>
SpringBoot | 第一章:构建第一个SpringBoot工程
查看>>
SpringBoot | 第二章:配置多环境以及上传文件
查看>>
Spring Data JPA |自定义非实体类的映射
查看>>
SpringBoot | 常用注解记录
查看>>
JAVA字符串格式化-String.format()的使用
查看>>
SpringBoot | CXF发布WebService服务和客户端调用WebService服务
查看>>
JavaBean对象转换EntityUtils工具类
查看>>
@JSONField和 @JsonFormat比较说明
查看>>
记录fastjson的使用
查看>>
SoapUI在头部传入用户名和密码
查看>>
2018 IntelliJ IDEA 常用设置
查看>>
SpringBoot | Mybatis通用mapper的分页查询
查看>>
驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:SQL Server 未返回响应。连接已关闭。
查看>>
windows下mysql数据备份bat文件
查看>>
windows下oracle数据备份bat文件
查看>>
windows下sqlserver数据库备份
查看>>
SpringBoot之打包成war包部署到tomcat
查看>>