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 # Stop process by process name
16 NOVA_API_PROCESS_1="nova-api-os-compute"
17 NOVA_API_PROCESS_2="nova-api-metadata"
18 NOVA_API_LXC_FILTER_1="nova_api_os_compute"
19 NOVA_API_LXC_FILTER_2="nova_api_metadata"
23 lxc_filter=$(echo "${process_name}" | sed 's/-/_/g')
25 if [ "${lxc_filter}" = "glance_api" ]; then
29 if [ "${process_name}" = "nova-api" ]; then
30 container_1=$(lxc-ls -1 --filter="${NOVA_API_LXC_FILTER_1}")
31 container_2=$(lxc-ls -1 --filter="${NOVA_API_LXC_FILTER_2}")
33 pids_1=$(lxc-attach -n "${container_1}" -- pgrep -f "/openstack/.*/${NOVA_API_PROCESS_1}")
36 lxc-attach -n "${container_1}" -- kill -9 "${pid}"
39 pids_2=$(lxc-attach -n "${container_2}" -- pgrep -f "/openstack/.*/${NOVA_API_PROCESS_2}")
42 lxc-attach -n "${container_2}" -- kill -9 "${pid}"
45 container=$(lxc-ls -1 --filter="${lxc_filter}")
47 if [ "${process_name}" = "haproxy" ]; then
48 for pid in $(pgrep -cf "/usr/.*/${process_name}");
52 elif [ "${process_name}" = "keystone" ]; then
53 pids=$(lxc-attach -n "${container}" -- ps aux | grep "keystone" | grep -iv heartbeat | grep -iv monitor | grep -v grep | grep -v /bin/sh | awk '{print $2}')
56 lxc-attach -n "${container}" -- kill -9 "${pid}"
59 pids=$(lxc-attach -n "${container}" -- pgrep -f "/openstack/.*/${process_name}")
62 lxc-attach -n "${container}" -- kill -9 "${pid}"