accept /etc/invirt/{nolvm,nocreate} on remote-server
[invirt/packages/invirt-remote.git] / server / usr / sbin / invirt-remote-proxy
1 #!/bin/bash
2 # invoke as invirt-remote-proxy-$TYPE, with "TYPE" in the remctl sense.
3
4 klist -s || kinit -k
5
6 TYPE="${0##*-}"
7 case "$TYPE" in
8     control )
9         MACHINE="$1"; SERVICE="$2"; shift; shift ;;
10     * )
11         SERVICE="$1"; shift ;;
12 esac
13
14 case "$TYPE/$SERVICE" in
15     web/listvms )
16         invirt-remote-listvms "$@" ;;
17     web/vnccert )
18         invirt-remote-vnccert "$@" ;;
19     web/availability )
20         invirt-remote-availability "$@" ;;
21     web/lvcreate | web/lvremove | web/lvrename | web/lvresize )
22         if [ -f "/etc/invirt/nolvm" ]; then
23             echo "LVM operations are temporarily disabled for maintenance, sorry."
24             exit 2
25         fi
26         remctl "$(invirt-getconf hosts.0.hostname)" remote "$TYPE" "$SERVICE" "$@" ;;
27     control/help )
28         invirt-remctl-help ;;
29     control/create|control/install )
30         if [ -f "/etc/invirt/nocreate" ]; then
31             echo "Booting VMs is temporarily disabled for maintenance, sorry."
32             exit 2
33         fi
34         invirt-remote-create "$SERVICE" "$MACHINE" "$@" ;;
35     control/listhost|control/list-host )
36         invirt-remote-listhost "$MACHINE" "$@" ;;
37     control/* )
38         # Everything but create must go where the VM is already running.
39         invirt-remote-control "$MACHINE" "$SERVICE" "$@" ;;
40     * )
41         echo "ERROR: invalid subcommand"
42         exit 34
43         ;;
44 esac