summaryrefslogtreecommitdiff
path: root/debian/nova-common.postinst.in
blob: a98d4058d1fcc16468acb52d7cff8badc7d8109d (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/sh

set -e

NOVA_CONF=/etc/nova/nova.conf

#PKGOS-INCLUDE#

manage_nova_api_field () {
	db_get nova/active-api
	if [ -n "${RET}" ] ; then
		# We get an answer from a multiselect debconf, so we trim spaces out
		# before putting it in the config file
		NOVA_APIS=`echo ${RET} | sed "s/ //g"`
		pkgos_inifile set ${NOVA_CONF} DEFAULT enabled_apis ${NOVA_APIS}
	fi
}

manage_nova_my_ip_field () {
	db_get nova/my-ip
	if [ -n "${RET}" ] ; then
		pkgos_inifile set ${NOVA_CONF} DEFAULT my_ip ${RET}
	fi
}

manage_keystone_auth_fields () {
	db_get nova/auth-host
	pkgos_inifile set ${NOVA_CONF} keystone_authtoken auth_host ${RET}
	db_get nova/admin-tenant-name
	pkgos_inifile set ${NOVA_CONF} keystone_authtoken admin_tenant_name ${RET}
	db_get nova/admin-user
	pkgos_inifile set ${NOVA_CONF} keystone_authtoken admin_user ${RET}
	db_get nova/admin-password
	if [ -n "${RET}" ] ; then
		pkgos_inifile set ${NOVA_CONF} keystone_authtoken admin_password ${RET}
	fi
}

maintain_var_lib_nova_perms () {
	if [ -z "$2" ]; then
		# New install - blanket permissions
		chown -R nova:nova /var/lib/nova/
	elif dpkg --compare-versions "$2" lt "2011.3"; then
		# Make sure the LXC rootfs mount points are excluded
		# during upgrades from previous versions
		find /var/lib/nova/ -name 'rootfs' -prune -o \
			-group root -a -user nova -exec chown nova:nova {} \;
		find /var/lib/nova/ -name 'rootfs' -prune -o \
			-group nogroup -a -user nova -exec chown nova:nova {} \;
	fi
	chmod 0755 /var/lib/nova
}

read_neutron_config () {
	db_get nova/neutron_url
	pkgos_inifile set ${NOVA_CONF} DEFAULT neutron_url ${RET}
	db_get nova/neutron_admin_tenant_name
	pkgos_inifile set ${NOVA_CONF} DEFAULT neutron_admin_tenant_name ${RET}
	db_get nova/neutron_admin_username
	pkgos_inifile set ${NOVA_CONF} DEFAULT neutron_admin_username ${RET}
	db_get nova/neutron_admin_password
	pkgos_inifile set ${NOVA_CONF} DEFAULT neutron_admin_password ${RET}
}


if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ] ; then
	. /usr/share/debconf/confmodule
	. /usr/share/dbconfig-common/dpkg/postinst

	pkgos_var_user_group nova
	maintain_var_lib_nova_perms $@

	# Create config files if they don't exist
	pkgos_write_new_conf nova nova.conf
	pkgos_write_new_conf nova api-paste.ini
	pkgos_write_new_conf nova logging.conf

	# Tweak config files depending on debconf answers
	pkgos_dbc_postinst /etc/nova/nova.conf database connection nova $@
	pkgos_rabbit_write_conf /etc/nova/nova.conf DEFAULT nova
	manage_nova_api_field
	manage_nova_my_ip_field
	manage_keystone_auth_fields

	# Needed, because in some cases, it's owned by root:root,
	# which makes the nova-manage db sync fail.
	touch /var/log/nova/nova-manage.log
	chown nova:nova /var/log/nova/nova-manage.log

	db_get nova/configure_db
	if [ "$RET" = "true" ]; then
		echo "nova-common: Now running \"nova-manage db sync\", this may take a while..."
		su nova -c "nova-manage db sync" || true
	fi

	db_stop

	# Fixup sudoers rights and clean old config file location
	chmod 0440 /etc/sudoers.d/nova-common
	[ -f /etc/sudoers.d/nova_sudoers ] && rm -f /etc/sudoers.d/nova_sudoers # That's the old file that we get rid of
fi

#DEBHELPER#

exit 0