Compass will be containerized in Euphrates release.
This work is about support HA testcase in a containerized environment.
Change-Id: Ibb668c81f046d6400293f8cd58181b9f20aeebe3
Signed-off-by: JingLu5 <lvjing5@huawei.com>
   inject_script: ha_tools/fault_process_kill.bash
   recovery_script: ha_tools/start_service.bash
 
+kill-lxc-process:
+  check_script: ha_tools/check_lxc_process_python.bash
+  inject_script: ha_tools/fault_lxc_process_kill.bash
+  recovery_script: ha_tools/start_lxc_service.bash
+
 bare-metal-down:
   check_script: ha_tools/check_host_ping.bash
   recovery_script: ha_tools/ipmi_power.bash
 
 block-io:
   inject_script: ha_tools/disk/block_io.bash
-  recovery_script: ha_tools/disk/recovery_disk_io.bash
\ No newline at end of file
+  recovery_script: ha_tools/disk/recovery_disk_io.bash
 
--- /dev/null
+#!/bin/sh
+
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# check the status of a service
+
+set -e
+
+NOVA_API_PROCESS_1="nova-api-os-compute"
+NOVA_API_PROCESS_2="nova-api-metadata"
+NOVA_API_LXC_FILTER_1="nova_api_os_compute"
+NOVA_API_LXC_FILTER_2="nova_api_metadata"
+
+process_name=$1
+
+lxc_filter=$(echo "${process_name}" | sed 's/-/_/g')
+
+if [ "${lxc_filter}" = "glance_api" ]; then
+    lxc_filter="glance"
+fi
+
+if [ "${process_name}" = "nova-api" ]; then
+    container_1=$(lxc-ls -1 --filter="${NOVA_API_LXC_FILTER_1}")
+    container_2=$(lxc-ls -1 --filter="${NOVA_API_LXC_FILTER_2}")
+
+   echo $(($(lxc-attach -n "${container_1}" -- ps aux | grep -e "${NOVA_API_PROCESS_1}" | grep -v grep | grep -cv /bin/sh) + $(lxc-attach -n "${container_2}" -- ps aux | grep -e "${NOVA_API_PROCESS_2}" | grep -v grep | grep -cv /bin/sh)))
+else
+    container=$(lxc-ls -1 --filter="${lxc_filter}")
+
+    if [ "${process_name}" = "haproxy" ]; then
+        ps aux | grep -e "/usr/.*/${process_name}" | grep -v grep | grep -cv /bin/sh
+    else
+        lxc-attach -n "${container}" -- ps aux | grep -e "${process_name}" | grep -v grep | grep -cv /bin/sh
+    fi
+fi
 
--- /dev/null
+#!/bin/sh
+
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# Stop process by process name
+
+set -e
+
+NOVA_API_PROCESS_1="nova-api-os-compute"
+NOVA_API_PROCESS_2="nova-api-metadata"
+NOVA_API_LXC_FILTER_1="nova_api_os_compute"
+NOVA_API_LXC_FILTER_2="nova_api_metadata"
+
+process_name=$1
+
+lxc_filter=$(echo "${process_name}" | sed 's/-/_/g')
+
+if [ "${lxc_filter}" = "glance_api" ]; then
+    lxc_filter="glance"
+fi
+
+if [ "${process_name}" = "nova-api" ]; then
+    container_1=$(lxc-ls -1 --filter="${NOVA_API_LXC_FILTER_1}")
+    container_2=$(lxc-ls -1 --filter="${NOVA_API_LXC_FILTER_2}")
+
+    pids_1=$(lxc-attach -n "${container_1}" -- pgrep -f "/openstack/.*/${NOVA_API_PROCESS_1}")
+    for pid in ${pids_1};
+        do
+            lxc-attach -n "${container_1}" -- kill -9 "${pid}"
+        done
+
+    pids_2=$(lxc-attach -n "${container_2}" -- pgrep -f "/openstack/.*/${NOVA_API_PROCESS_2}")
+    for pid in ${pids_2};
+        do
+            lxc-attach -n "${container_2}" -- kill -9 "${pid}"
+        done
+else
+    container=$(lxc-ls -1 --filter="${lxc_filter}")
+
+    if [ "${process_name}" = "haproxy" ]; then
+        for pid in $(pgrep -cf "/usr/.*/${process_name}");
+            do
+                kill -9 "${pid}"
+            done
+    elif [ "${process_name}" = "keystone" ]; then
+        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}')
+        for pid in ${pids};
+            do
+                lxc-attach -n "${container}" -- kill -9 "${pid}"
+            done
+    else
+        pids=$(lxc-attach -n "${container}" -- pgrep -f "/openstack/.*/${process_name}")
+        for pid in ${pids};
+            do
+                lxc-attach -n "${container}" -- kill -9 "${pid}"
+            done
+    fi
+fi
 
     SECURE=""
 fi
 
-openstack "${SECURE}" flavor create $1 --id $2 --ram $3 --disk $4 --vcpus $5
+openstack ${SECURE} flavor create $1 --id $2 --ram $3 --disk $4 --vcpus $5
 
     SECURE=""
 fi
 
-openstack "${SECURE}" flavor delete $1
+openstack ${SECURE} flavor delete $1
 
     SECURE=""
 fi
 
-openstack "${SECURE}" flavor list
+openstack ${SECURE} flavor list
 
--- /dev/null
+#!/bin/bash
+
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# Start a service and check the service is started
+
+set -e
+
+NOVA_API_SERVICE_1="nova-api-os-compute"
+NOVA_API_SERVICE_2="nova-api-metadata"
+NOVA_API_LXC_FILTER_1="nova_api_os_compute"
+NOVA_API_LXC_FILTER_2="nova_api_metadata"
+
+service_name=$1
+
+if [ "${service_name}" = "haproxy" ]; then
+    if which systemctl 2>/dev/null; then
+        systemctl start $service_name
+    else
+        service $service_name start
+    fi
+else
+    lxc_filter=${service_name//-/_}
+
+    if [ "${lxc_filter}" = "glance_api" ]; then
+        lxc_filter="glance"
+    fi
+
+    if [ "${service_name}" = "nova-api" ]; then
+        container_1=$(lxc-ls -1 --filter="${NOVA_API_LXC_FILTER_1}")
+        container_2=$(lxc-ls -1 --filter="${NOVA_API_LXC_FILTER_2}")
+
+        if lxc-attach -n "${container_1}" -- which systemctl 2>/dev/null; then
+            lxc-attach -n "${container_1}" -- systemctl start "${NOVA_API_SERVICE_1}"
+        else
+            lxc-attach -n "${container_1}" -- service "${NOVA_API_SERVICE_1}" start
+        fi
+
+        if lxc-attach -n "${container_2}" -- which systemctl 2>/dev/null; then
+            lxc-attach -n "${container_2}" -- systemctl start "${NOVA_API_SERVICE_2}"
+        else
+            lxc-attach -n "${container_2}" -- service "${NOVA_API_SERVICE_2}" start
+        fi
+    else
+        container=$(lxc-ls -1 --filter="${lxc_filter}")
+
+        Distributor=$(lxc-attach -n "${container}" -- lsb_release -a | grep "Distributor ID" | awk '{print $3}')
+
+        if [ "${Distributor}" != "Ubuntu" -a "${service_name}" != "keystone" -a "${service_name}" != "neutron-server" ]; then
+            service_name="openstack-"${service_name}
+        elif [ "${Distributor}" = "Ubuntu" -a "${service_name}" = "keystone" ]; then
+            service_name="apache2"
+        elif [ "${service_name}" = "keystone" ]; then
+            service_name="httpd"
+        fi
+
+        if lxc-attach -n "${container}" -- which systemctl 2>/dev/null; then
+            lxc-attach -n "${container}" -- systemctl start "${service_name}"
+        else
+            lxc-attach -n "${container}" -- service "${service_name}" start
+        fi
+    fi
+fi
 
 
 process-status:
   monitor_script: ha_tools/check_process_python.bash
+lxc_process-status:
+  monitor_script: ha_tools/check_lxc_process_python.bash
 nova-image-list:
   monitor_script: ha_tools/nova_image_list.bash
 service-status: