You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.0 KiB
35 lines
1.0 KiB
#!/bin/bash |
|
|
|
echo "wsargs=$@" |
|
|
|
guest_name="$1" |
|
operation="$2" |
|
|
|
# Operation migrate will: |
|
# 1. Trigger migrate->prepare->start->started operation on the destination host. |
|
# 2. Trigger stopped->release operations on the source host. |
|
if [[ "$operation" == "started" || "$operation" == "stopped" ]] |
|
then |
|
ws_open_flag="" |
|
ws_port_flag="" |
|
|
|
if [[ "$operation" == "started" ]] |
|
then |
|
ws_open_flag="--open" |
|
|
|
# libvirt hooks cannot call anything related to libvirt, i.e., |
|
# virsh because a deadlock will happen. |
|
server_vnc_port=$(grep "<graphics.*type=['\"]vnc['\"]" - | grep -oPm1 "(?<=port=['\"])\d+") |
|
ws_port_flag="--server-vnc-port ${server_vnc_port}" |
|
|
|
local_host_uuid=$(</etc/anvil/host.uuid) |
|
|
|
update_sql="UPDATE servers SET server_host_uuid = '$local_host_uuid' WHERE server_name = '$guest_name';" |
|
echo "update=$update_sql" |
|
anvil-access-module --query "$update_sql" --mode write |
|
fi |
|
|
|
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
|
|
|