+ done
+ if [[ "$expected_state" =~ "$host_status" ]] ; then
+ echo "${VM_BASENAME}1 showing host_status: $host_status"
+ else
+ die $LINENO "host_status:$host_status not equal to expected_state: $expected_state"
+ fi
+}
+
+unset_forced_down_hosts() {
+ # for debug
+ openstack compute service list --service nova-compute
+
+ downed_computes=$(openstack compute service list --service nova-compute \
+ -f value -c Host -c State | grep ' down$' \
+ | sed -e 's/ *down$//')
+ echo "downed_computes: $downed_computes"
+ for host in $downed_computes
+ do
+ # TODO(r-mibu): use openstack client
+ #openstack compute service set --up $host nova-compute
+ nova service-force-down --unset $host nova-compute
+ done
+
+ echo "waiting disabled compute host back to be enabled..."
+ wait_until 'openstack compute service list --service nova-compute
+ -f value -c State | grep -q down' 240 5
+
+ for host in $downed_computes
+ do
+ # TODO(r-mibu): improve 'get_compute_ip_from_hostname'
+ get_compute_ip_from_hostname $host
+ wait_until "! ping -c 1 $COMPUTE_IP" 120 5
+ done
+}
+
+collect_logs() {
+ if [[ -n "$COMPUTE_IP" ]];then
+ scp $ssh_opts_cpu "$COMPUTE_USER@$COMPUTE_IP:disable_network.log" .
+ fi
+
+ # TODO(yujunz) collect other logs, e.g. nova, aodh
+}
+
+run_profiler() {
+ if [[ "$PROFILER_TYPE" == "poc" ]]; then
+ linkdown=$(grep "doctor set link down at " disable_network.log |\
+ sed -e "s/^.* at //")
+ vmdown=$(grep "doctor mark vm.* error at" inspector.log |tail -n 1 |\
+ sed -e "s/^.* at //")
+ hostdown=$(grep "doctor mark host.* down at" inspector.log |\
+ sed -e "s/^.* at //")
+
+ # TODO(yujunz) check the actual delay to verify time sync status
+ # expected ~1s delay from $trigger to $linkdown
+ relative_start=${linkdown}
+ export DOCTOR_PROFILER_T00=$(python -c \
+ "print(int(($linkdown-$relative_start)*1000))")
+ export DOCTOR_PROFILER_T01=$(python -c \
+ "print(int(($detected-$relative_start)*1000))")
+ export DOCTOR_PROFILER_T03=$(python -c \
+ "print(int(($vmdown-$relative_start)*1000))")
+ export DOCTOR_PROFILER_T04=$(python -c \
+ "print(int(($hostdown-$relative_start)*1000))")
+ export DOCTOR_PROFILER_T09=$(python -c \
+ "print(int(($notified-$relative_start)*1000))")
+
+ python profiler-poc.py >doctor_profiler.log 2>&1
+ fi