parent
dc78a8ccf1
commit
f29ccb96d5
1 changed files with 42 additions and 29 deletions
@ -1,35 +1,48 @@ |
|||||||
#!/bin/bash |
#!/bin/bash |
||||||
|
|
||||||
echo "wsargs=$@" |
{ |
||||||
|
echo "wsargs=$@" |
||||||
|
|
||||||
guest_name="$1" |
domain_xml=$(</dev/stdin) |
||||||
operation="$2" |
guest_name="$1" |
||||||
|
operation="$2" |
||||||
|
|
||||||
# Operation migrate will: |
# Operation migrate will: |
||||||
# 1. Trigger migrate->prepare->start->started operation on the destination host. |
# 1. Trigger migrate->prepare->start->started operation on the destination host. |
||||||
# 2. Trigger stopped->release operations on the source host. |
# 2. Trigger stopped->release operations on the source host. |
||||||
if [[ "$operation" == "started" || "$operation" == "stopped" ]] |
if [[ "$operation" == "started" || "$operation" == "stopped" ]] |
||||||
then |
|
||||||
ws_open_flag="" |
|
||||||
ws_port_flag="" |
|
||||||
|
|
||||||
if [[ "$operation" == "started" ]] |
|
||||||
then |
then |
||||||
ws_open_flag="--open" |
ws_open_flag="" |
||||||
|
ws_port_flag="" |
||||||
# libvirt hooks cannot call anything related to libvirt, i.e., |
ws_suuid_flag="" |
||||||
# virsh because a deadlock will happen. |
|
||||||
server_vnc_port=$(grep "<graphics.*type=['\"]vnc['\"]" - | grep -oPm1 "(?<=port=['\"])\d+") |
if [[ "$operation" == "started" ]] |
||||||
ws_port_flag="--server-vnc-port ${server_vnc_port}" |
then |
||||||
|
ws_open_flag="--open" |
||||||
local_host_uuid=$(</etc/anvil/host.uuid) |
|
||||||
|
# Cannot call $ virsh vncdisplay... because libvirt hooks |
||||||
update_sql="UPDATE servers SET server_host_uuid = '$local_host_uuid' WHERE server_name = '$guest_name';" |
# cannot call anything related to libvirt, i.e., virsh, because |
||||||
echo "update=$update_sql" |
# a deadlock will happen. |
||||||
anvil-access-module --query "$update_sql" --mode write |
server_vnc_port=$( grep "<graphics.*type=['\"]vnc['\"]" <<<$domain_xml | grep -oPm1 "(?<=port=['\"])\d+" ) |
||||||
|
ws_port_flag="--server-vnc-port ${server_vnc_port}" |
||||||
|
|
||||||
|
server_uuid=$( grep -oPm1 "(?<=<uuid>)[^\s]+(?=<)" <<<$domain_xml ) |
||||||
|
ws_suuid_flag="--server-uuid ${server_uuid}" |
||||||
|
|
||||||
|
local_host_uuid=$(</etc/anvil/host.uuid) |
||||||
|
|
||||||
|
update_sql="UPDATE servers SET server_host_uuid = '$local_host_uuid' WHERE server_name = '$guest_name';" |
||||||
|
echo "wsupdate=$update_sql" |
||||||
|
anvil-access-module --query "$update_sql" --mode write |
||||||
|
fi |
||||||
|
|
||||||
|
ws_command_args="--server \"$guest_name\" $ws_suuid_flag --server-host-uuid local $ws_port_flag --component ws $ws_open_flag" |
||||||
|
echo "wscmd=$ws_command_args" |
||||||
|
striker-manage-vnc-pipes --server "$guest_name" $ws_suuid_flag --server-host-uuid local $ws_port_flag --component ws $ws_open_flag |
||||||
|
echo "wscmd_exit=$?" |
||||||
|
|
||||||
|
# Don't interrupt libvirt regardless of whether websockify gets setup |
||||||
|
# successfully. |
||||||
|
exit 0 |
||||||
fi |
fi |
||||||
|
} >>/var/log/anvil.log |
||||||
ws_command="striker-manage-vnc-pipes --server ${guest_name} --server-host-uuid local ${ws_port_flag} --component ws ${ws_open_flag}" |
|
||||||
echo "wscmd=$ws_command" |
|
||||||
$ws_command |
|
||||||
fi |
|
||||||
|
Loading…
Reference in new issue