summaryrefslogtreecommitdiff
path: root/debian/nova-common.config.in
blob: be7a6cc464c926c260aabbcb46464bac64c9cc9d (plain)
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
60
61
62
63
64
#!/bin/sh
set -e

. /usr/share/debconf/confmodule

NOVA_CONF=/etc/nova/nova.conf

#PKGOS-INCLUDE#

set_enabled_apis_multiselect () {
	local NOVA_APIS NOVA_API MULTISEL_VAL
	pkgos_inifile get ${NOVA_CONF} DEFAULT enabled_apis
	if [ -n "${RET}" ] && [ ! "${RET}" = "NOT_FOUND" ] ; then
		NOVA_APIS=`echo $RET | sed "s/,/ /g"`
		for NOVA_API in ${NOVA_APIS} ; do
			if [ -n "${MULTISEL_VAL}" ] ; then
				MULTISEL_VAL="${MULTISEL_VAL}, "
			fi
			MULTISEL_VAL="${MULTISEL_VAL}${NOVA_API}"
		done
		if [ -n "${MULTISEL_VAL}" ] ; then
			db_set nova/active-api ${MULTISEL_VAL}
		fi
	fi
	db_input high nova/active-api || true
	db_go
}

manage_nova_my_ip () {
	pkgos_inifile get ${NOVA_CONF} DEFAULT my_ip
	if [ -n "${RET}" ] && [ ! "${RET}" = "NOT_FOUND" ] ; then
		db_set nova/my-ip "${RET}"
	else
		if [ -r /proc/net/route ] && [ -x /sbin/route ] ; then
			DEFROUTE_IF=`LC_ALL=C /sbin/route | grep default |awk -- '{ print $8 }' | cut -d" " -f1`
			if [ -n "${DEFROUTE_IF}" ] ; then
				DEFROUTE_IP=`LC_ALL=C ip addr show "${DEFROUTE_IF}" | grep inet | head -n 1 | awk '{print $2}' | cut -d/ -f1 | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'`
				if [ -n "${DEFROUTE_IP}" ] ; then
					db_set nova/my-ip ${DEFROUTE_IP}
				fi
			fi
		fi
	fi
	db_input high nova/my-ip || true
	db_go
}

read_neutron_config () {
	pkgos_read_config -p high ${NOVA_CONF} DEFAULT neutron_url nova/neutron_url
	pkgos_read_config -p medium ${NOVA_CONF} DEFAULT neutron_admin_tenant_name nova/neutron_admin_tenant_name
	pkgos_read_config -p medium ${NOVA_CONF} DEFAULT neutron_admin_username nova/neutron_admin_username
	pkgos_read_config -p high ${NOVA_CONF} DEFAULT neutron_admin_password nova/neutron_admin_password
}

pkgos_var_user_group nova
pkgos_dbc_read_conf -pkg nova-common ${NOVA_CONF} database connection nova $@
pkgos_rabbit_read_conf ${NOVA_CONF} DEFAULT nova
pkgos_read_admin_creds ${NOVA_CONF} keystone_authtoken nova
read_neutron_config

set_enabled_apis_multiselect
manage_nova_my_ip

exit 0