-
Notifications
You must be signed in to change notification settings - Fork 6
/
bootdisk_provision
executable file
·60 lines (53 loc) · 1.48 KB
/
bootdisk_provision
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
#
# Foreman Hook to provision hosts using the foreman bootdisk
# Connects foreman bootdisk to the host, and configure boot
# options to boot the foreman bootdisk image.
#
# Arguments
# ARG1 = HOOK_EVENT (create, after_build, after_provision, destroy)
# ARG2 = HOOK_OBJECT (Foreman host FQDN)
# ARG3 = HOOK_OBJECT_FILE (Tempfile containing hook data in json)
#
HOOK_EVENT=$1
HOOK_OBJECT=$2
HOOK_OBJECT_FILE=$3
#
# Source the configuration file
#
source /etc/foreman/hooks/foreman_bootdisk.conf
#
# Source functions
#
source ${HOOK_DIR}/functions/hook_functions.sh
source ${HOOK_DIR}/functions/bootdisk_functions.sh
#
# Source the model specific functions
#
PROVIDERS_DIR=${HOOK_DIR}/providers
#source ${PROVIDERS_DIR}/libvirt.sh
#source ${PROVIDERS_DIR}/vmware.sh
source ${PROVIDERS_DIR}/ovirt.sh
#source ${PROVIDERS_DIR}/idrac.sh
case "$HOOK_EVENT" in
create|after_build)
provider_resolve # Figure out what is the provider behind the
# host. And set global variables.
provider_provision # Connect the bootdisk to the host, configure
# boot options, and power actions.
;;
after_provision)
provider_resolve
provider_post_provision
;;
destroy)
# Clean up?
# * Disconnect bootdisk from host if baremetal?
# * Reconfigure boot options if baremetal?
;;
*)
echo "Hook Usage: run_hooks {create|after_build|after_provision}"
exit 1
;;
esac
exit 0