3 ##############################################################################
4 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
12 # Start a service and check the service is started
16 NOVA_API_SERVICE_1="nova-api-os-compute"
17 NOVA_API_SERVICE_2="nova-api-metadata"
18 NOVA_API_LXC_FILTER_1="nova_api_os_compute"
19 NOVA_API_LXC_FILTER_2="nova_api_metadata"
23 if [ "${service_name}" = "haproxy" ]; then
24 if which systemctl 2>/dev/null; then
25 systemctl start $service_name
27 service $service_name start
30 lxc_filter=${service_name//-/_}
32 if [ "${lxc_filter}" = "glance_api" ]; then
36 if [ "${service_name}" = "nova-api" ]; then
37 container_1=$(lxc-ls -1 --filter="${NOVA_API_LXC_FILTER_1}")
38 container_2=$(lxc-ls -1 --filter="${NOVA_API_LXC_FILTER_2}")
40 if lxc-attach -n "${container_1}" -- which systemctl 2>/dev/null; then
41 lxc-attach -n "${container_1}" -- systemctl start "${NOVA_API_SERVICE_1}"
43 lxc-attach -n "${container_1}" -- service "${NOVA_API_SERVICE_1}" start
46 if lxc-attach -n "${container_2}" -- which systemctl 2>/dev/null; then
47 lxc-attach -n "${container_2}" -- systemctl start "${NOVA_API_SERVICE_2}"
49 lxc-attach -n "${container_2}" -- service "${NOVA_API_SERVICE_2}" start
52 container=$(lxc-ls -1 --filter="${lxc_filter}")
54 Distributor=$(lxc-attach -n "${container}" -- lsb_release -a | grep "Distributor ID" | awk '{print $3}')
56 if [ "${Distributor}" != "Ubuntu" -a "${service_name}" != "keystone" -a "${service_name}" != "neutron-server" ]; then
57 service_name="openstack-"${service_name}
58 elif [ "${Distributor}" = "Ubuntu" -a "${service_name}" = "keystone" ]; then
59 service_name="apache2"
60 elif [ "${service_name}" = "keystone" ]; then
64 if lxc-attach -n "${container}" -- which systemctl 2>/dev/null; then
65 lxc-attach -n "${container}" -- systemctl start "${service_name}"
67 lxc-attach -n "${container}" -- service "${service_name}" start