install -p -D -m 640 %{_builddir}/%{full_release}/etc/heat/heat.conf.sample %{buildroot}/%{_sysconfdir}/heat/heat.conf
install -p -D -m 640 %{SOURCE20} %{buildroot}%{_datadir}/heat/heat-dist.conf
-install -p -D -m 640 %{_builddir}/%{full_release}/etc/heat/api-paste.ini %{buildroot}/%{_datadir}/heat/api-paste-dist.ini
+install -p -D -m 640 %{_builddir}/%{full_release}/etc/heat/api-paste.ini %{buildroot}/%{_sysconfdir}/heat/api-paste.ini
install -p -D -m 640 etc/heat/policy.json %{buildroot}/%{_sysconfdir}/heat
# TODO: move this to setup.cfg
%{_bindir}/heat-keystone-setup-domain
%{python_sitelib}/heat*
%attr(-, root, heat) %{_datadir}/heat/heat-dist.conf
-%attr(-, root, heat) %{_datadir}/heat/api-paste-dist.ini
%dir %attr(0755,heat,root) %{_localstatedir}/log/heat
%dir %attr(0755,heat,root) %{_localstatedir}/run/heat
%dir %attr(0755,heat,root) %{_sharedstatedir}/heat
%dir %attr(0755,heat,root) %{_sysconfdir}/heat
%config(noreplace) %{_sysconfdir}/logrotate.d/openstack-heat
%config(noreplace) %attr(-, root, heat) %{_sysconfdir}/heat/heat.conf
+%config(noreplace) %attr(-, root, heat) %{_sysconfdir}/heat/api-paste.ini
%config(noreplace) %attr(-, root, heat) %{_sysconfdir}/heat/policy.json
%config(noreplace) %attr(-,root,heat) %{_sysconfdir}/heat/environment.d/*
%config(noreplace) %attr(-,root,heat) %{_sysconfdir}/heat/templates/*
/sbin/service openstack-heat-api-cfn condrestart >/dev/null 2>&1 || :
fi
-
%package api-cloudwatch
Summary: Heat CloudWatch API
Group: System Environment/Base
#!/bin/bash -x
-exit 0
+RES=0
+package=$1
+MYSQL_PASSWORD="heat"
+conf_file=/etc/heat/heat.conf
+
+prepare_vm() {
+ if [[ `cat /etc/*-release | head -n 1 | awk '{print $1}'` =~ Ubuntu ]]
+ then
+ echo "mysql-server mysql-server/root_password select $MYSQL_PASSWORD" | sudo debconf-set-selections
+ echo "mysql-server mysql-server/root_password_again select $MYSQL_PASSWORD" | sudo debconf-set-selections
+ apt-get install -y mysql-server python-mysqldb rabbitmq-server
+ else
+ yum install screen mysql-server MySQL-python rabbitmq-server -y
+ service mysqld start
+ /usr/bin/mysqladmin -u root password $MYSQL_PASSWORD
+ /usr/bin/mysqladmin -u root --password=$MYSQL_PASSWORD -h localhost $MYSQL_PASSWORD
+ fi
+ service rabbitmq-server start
+ mysql -uroot -p$MYSQL_PASSWORD -Bse "create database heat"
+ sed -i "/^\[database\]/a connection=mysql://root:$MYSQL_PASSWORD@localhost/heat" $conf_file
+ heat-manage -d db_sync
+ if [ "$?" != "0" ]
+ then
+ echo "Couldn't execute 'heat-manage db_sync'"
+ RES=1
+ fi
+}
+
+case $package in
+ openstack-heat-common)
+ python -c 'import heat'
+ if [ $? -ne '0' ]; then
+ echo -e "Couldn't import module 'heat'"
+ RES=1
+ fi
+ if [ -z "$(cut -d: -f1 /etc/passwd | grep 'heat')" ]; then
+ echo -e "User 'heat' doesn't exist"
+ RES=1
+ fi
+ files="policy.json api-paste.ini heat.conf"
+ for i in $config_files; do
+ if [ ! -f "/etc/heat/$i" ]; then
+ RES=1
+ echo "File /etc/heat/$i doesn't exist"
+ fi
+ done
+ ;;
+ python-heat)
+ python -c 'import heat'
+ if [ $? -ne '0' ]; then
+ echo -e "Couldn't import module 'heat'"
+ RES=1
+ fi
+ ;;
+ heat-common)
+ if [ -z "$(cut -d: -f1 /etc/passwd | grep 'heat')" ]; then
+ echo -e "User 'heat' doesn't exist"
+ RES=1
+ fi
+ files="policy.json api-paste.ini heat.conf"
+ for i in $config_files; do
+ if [ ! -f "/etc/heat/$i" ]; then
+ RES=1
+ echo "File /etc/heat/$i doesn't exist"
+ fi
+ done
+ ;;
+ heat-api|openstack-heat-api)
+ prepare_vm
+ screen -dmS heat-api
+ sleep 2
+ echo "Starting Heat API..."
+ screen -S heat-api -p 0 -X stuff "heat-api --config-file $conf_file -d --log-file /tmp/heat-api.log
+"
+ sleep 5
+ curl_req=`curl http://localhost:8004/v1/tenant/stacks`
+ cat /tmp/heat-api.log
+ if [ `netstat -nat | grep 8004 | wc -l` != 0 ] && [[ $curl_req =~ Auth ]]
+ then
+ echo "Heat API successfully started"
+ else
+ echo "Heat API didn't start"
+ RES=1
+ fi
+ ;;
+ heat-engine|openstack-heat-engine)
+ prepare_vm
+ screen -dmS heat-engine
+ sleep 2
+ echo "Starting Heat Engine..."
+ screen -S heat-engine -p 0 -X stuff "heat-engine --config-file $conf_file -d --log-file /tmp/heat-engine.log
+"
+ sleep 5
+ cat /tmp/heat-engine.log
+ trace_count=`cat /tmp/heat-engine.log | grep -i Traceback | wc -l`
+ if [ "$trace_count" -ne "0" ]
+ then
+ echo "Something went wrong! Log file have trace errors! Check logs"
+ RES=1
+ else
+ rabbit_connections=`cat /tmp/heat-engine.log | grep 'Connected to AMQP server on' | wc -l`
+ if [ "$rabbit_connections" -eq "0" ]
+ then
+ echo "Heat Engine: Can't connected to RabbitMQ"
+ RES=1
+ else
+ echo "Heat Engine successfully started"
+ fi
+ fi
+ ;;
+ heat-api-cfn|openstack-heat-api-cfn)
+ prepare_vm
+ screen -dmS heat-api-cfn
+ sleep 2
+ echo "Starting Heat API CFN..."
+ screen -S heat-api-cfn -p 0 -X stuff "heat-api-cfn --config-file $conf_file -d --log-file /tmp/heat-api-cfn.log
+"
+ sleep 5
+ cat /tmp/heat-api-cfn.log
+ check_start_cfn=`cat /tmp/heat-api-cfn.log | grep 'Starting Heat API on' | wc -l`
+ if [ "$check_start_cfn" -ne "0" ]
+ then
+ echo "Heat API CFN successfully started"
+ else
+ RES=1
+ echo "Heat API CFN didn't start"
+ fi
+ ;;
+ heat-api-cloudwatch|openstack-heat-api-cloudwatch)
+ prepare_vm
+ screen -dmS heat-api-clw
+ sleep 2
+ echo "Starting Heat API Cloudwatch..."
+ screen -S heat-api-clw -p 0 -X stuff "heat-api-cloudwatch --config-file $conf_file -d --log-file /tmp/heat-api-clw.log
+"
+ sleep 5
+ cat /tmp/heat-api-clw.log
+ check_start_clw=`cat /tmp/heat-api-clw.log | grep 'Starting Heat CloudWatch API on' | wc -l`
+ if [ "$check_start_clw" -ne "0" ]
+ then
+ echo "Heat API Cloudwatch successfully started"
+ else
+ RES=1
+ echo "Heat API Cloudwatch didn't start"
+ fi
+ ;;
+ *)
+ echo "test not defined, skipping..."
+ ;;
+esac
+killall -15 screen
+exit $RES