Update neutron to 9.0.0~b3
[openstack-build/neutron-build.git] / xenial / debian / neutron-common.config.in
1 #!/bin/sh
2
3 set -e
4
5 . /usr/share/debconf/confmodule
6
7 N_CONF=/etc/neutron/neutron.conf
8 OVS_CONF=/etc/neutron/plugins/ml2/openvswitch_agent.ini
9
10 # Please remember this function is also in debian/plugin_guess_func
11 neutron_core_plugin_to_plugin_name () {
12         case ${1} in
13         "neutron.plugins.ml2.plugin.Ml2Plugin"|"ml2")
14                 NEUTRON_PLUGIN_NAME=ml2
15         ;;
16         "networking_plumgrid.neutron.plugins.plugin:NeutronPluginPLUMgridV2"|"plumgrid")
17                 NEUTRON_PLUGIN_NAME=plumgrid
18         ;;
19         "midonet.neutron.plugin_v1:MidonetPluginV2"|"modonet")
20                 NEUTRON_PLUGIN_NAME=midonet
21         ;;
22         "midonet.neutron.plugin_v2:MidonetPluginV2"|"midonet_v2")
23                 NEUTRON_PLUGIN_NAME=midonet_v2
24         ;;
25         "networking_nec.nwa.l2.plugin:NECNWAL2Plugin"|"necnwa")
26                 NEUTRON_PLUGIN_NAME=nec
27         ;;
28         "neutron.plugins.mlnx.mlnx_plugin.MellanoxEswitchPlugin")
29                 NEUTRON_PLUGIN_NAME=mellanox
30         ;;
31         "vmware_nsx.plugin:NsxMhPlugin"|"vmware")
32                 NEUTRON_PLUGIN_NAME=vmware
33         ;;
34         *)
35                 NEUTRON_PLUGIN_NAME="other"
36         ;;
37         esac
38 }
39
40 #PKGOS-INCLUDE#
41
42 pkgos_var_user_group neutron
43 chmod 755 /var/lib/neutron
44
45 # Configure the SQL connection
46 pkgos_dbc_read_conf -pkg neutron-common ${N_CONF} database connection neutron $@
47 pkgos_rabbit_read_conf ${N_CONF} oslo_messaging_rabbit neutron
48
49 # Configure the keystone_authtoken
50 pkgos_read_admin_creds ${N_CONF} keystone_authtoken neutron
51
52 # Select which plugin to use
53 if [ -r "${N_CONF}" ] ; then
54         pkgos_inifile get ${N_CONF} DEFAULT core_plugin
55         if [ -n "${RET}" ] ; then
56                 NEUTRON_CORE_PLUGIN_CLASS=${RET}
57                 neutron_core_plugin_to_plugin_name ${NEUTRON_CORE_PLUGIN_CLASS}
58                 db_set neutron/plugin-select ${NEUTRON_PLUGIN_NAME}
59         fi
60 fi
61 db_input high neutron/plugin-select || true
62 db_go
63 db_get neutron/plugin-select
64 NEUTRON_PLUGIN_NAME=${RET}
65
66 read_nova_admin_credentials () {
67         pkgos_read_config -p high ${N_CONF} nova url neutron/nova_url
68         pkgos_read_config -p high ${N_CONF} nova region_name neutron/nova_region
69         pkgos_read_config -p medium ${N_CONF} nova project_name neutron/nova_admin_tenant_name
70         pkgos_read_config -p medium ${N_CONF} nova username neutron/nova_admin_username
71         pkgos_read_config -p high ${N_CONF} nova password neutron/nova_admin_password
72 }
73
74 # OVS specific configurations (if that's the one selected)
75 if [ "${NEUTRON_PLUGIN_NAME}" = "OpenVSwitch" ] ; then
76         # Various network config...
77         pkgos_read_config ${OVS_CONF} OVS tenant_network_type   neutron/tenant_network_type
78         pkgos_read_config ${OVS_CONF} OVS enable_tunneling      neutron/enable_tunneling
79         pkgos_read_config ${OVS_CONF} OVS tunnel_id_ranges      neutron/tunnel_id_ranges
80
81         read_nova_admin_credentials
82
83         # Guess values to put in the local_ip directive
84         IF=`LC_ALL=C route | grep default |awk -- '{ print $8 }'`
85         guessed_ip_addr=`LC_ALL=C ifconfig ${IF} | grep 'inet addr' | sed 's/.\+inet addr:\([0-9.]\+\).\+/\1/'`
86         if [ -z "${guessed_ip_addr}" ] ; then
87                 guessed_ip_addr=`LC_ALL=C ifconfig ${IF} | grep 'inet adr' | sed 's/.\+inet adr:\([0-9.]\+\).\+/\1/'`
88         fi
89         db_set neutron/local_ip ${guessed_ip_addr}
90         pkgos_read_config ${OVS_CONF} OVS local_ip neutron/local_ip
91 fi
92
93 exit 0