46e8e8ed55a2e9d5491ed749209dcf94e879fd47
[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.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2")
14                 NEUTRON_PLUGIN_NAME=OpenVSwitch
15         ;;
16         "neutron.plugins.linuxbridge.lb_neutron_plugin.LinuxBridgePluginV2")
17                 NEUTRON_PLUGIN_NAME=LinuxBridge
18         ;;
19         "neutron.plugins.ml2.plugin.Ml2Plugin")
20                 NEUTRON_PLUGIN_NAME=ml2
21         ;;
22         "neutron.plugins.ryu.ryu_neutron_plugin.RyuNeutronPluginV2")
23                 NEUTRON_PLUGIN_NAME=RYU
24         ;;
25         "neutron.plugins.plumgrid.plumgrid_nos_plugin.plumgrid_plugin.NeutronPluginPLUMgridV2")
26                 NEUTRON_PLUGIN_NAME=PLUMgrid
27         ;;
28         "neutron.plugins.brocade.NeutronPlugin.BrocadePluginV2")
29                 NEUTRON_PLUGIN_NAME=Brocade
30         ;;
31         "neutron.plugins.hyperv.hyperv_neutron_plugin.HyperVNeutronPlugin")
32                 NEUTRON_PLUGIN_NAME=Hyper-V
33         ;;
34         "neutron.plugins.bigswitch.plugin.NeutronRestProxyV2")
35                 NEUTRON_PLUGIN_NAME=BigSwitch
36         ;;
37         "neutron.plugins.cisco.network_plugin.PluginV2")
38                 NEUTRON_PLUGIN_NAME=Cisco
39         ;;
40         "neutron.plugins.nicira.NeutronPlugin.NvpPluginV2")
41                 NEUTRON_PLUGIN_NAME=neutron.plugins.nicira.NeutronPlugin.NvpPluginV2
42         ;;
43         "neutron.plugins.midonet.plugin.MidonetPluginV2")
44                 NEUTRON_PLUGIN_NAME=Midonet
45         ;;
46         "neutron.plugins.nec.nec_plugin.NECPluginV2")
47                 NEUTRON_PLUGIN_NAME=Nec
48         ;;
49         "neutron.plugins.metaplugin.meta_neutron_plugin.MetaPluginV2")
50                 NEUTRON_PLUGIN_NAME=MetaPlugin
51         ;;
52         "neutron.plugins.mlnx.mlnx_plugin.MellanoxEswitchPlugin")
53                 NEUTRON_PLUGIN_NAME=Mellanox
54         ;;
55         "vmware_nsx.plugin.NsxVPlugin")
56                 NEUTRON_PLUGIN_NAME=VMware
57         ;;
58         *)
59                 NEUTRON_PLUGIN_NAME="other"
60         ;;
61         esac
62 }
63
64 #PKGOS-INCLUDE#
65
66 pkgos_var_user_group neutron
67 chmod 755 /var/lib/neutron
68
69 # Configure the SQL connection
70 pkgos_dbc_read_conf -pkg neutron-common ${N_CONF} database connection neutron $@
71 pkgos_rabbit_read_conf ${N_CONF} oslo_messaging_rabbit neutron
72
73 # Configure the keystone_authtoken
74 pkgos_read_admin_creds ${N_CONF} keystone_authtoken neutron
75
76 # Select which plugin to use
77 if [ -r "${N_CONF}" ] ; then
78         pkgos_inifile get ${N_CONF} DEFAULT core_plugin
79         if [ -n "${RET}" ] ; then
80                 NEUTRON_CORE_PLUGIN_CLASS=${RET}
81                 neutron_core_plugin_to_plugin_name ${NEUTRON_CORE_PLUGIN_CLASS}
82                 db_set neutron/plugin-select ${NEUTRON_PLUGIN_NAME}
83         fi
84 fi
85 db_input high neutron/plugin-select || true
86 db_go
87 db_get neutron/plugin-select
88 NEUTRON_PLUGIN_NAME=${RET}
89
90 read_nova_admin_credentials () {
91         pkgos_read_config -p high ${N_CONF} nova url neutron/nova_url
92         pkgos_read_config -p high ${N_CONF} nova region_name neutron/nova_region
93         pkgos_read_config -p medium ${N_CONF} nova project_name neutron/nova_admin_tenant_name
94         pkgos_read_config -p medium ${N_CONF} nova username neutron/nova_admin_username
95         pkgos_read_config -p high ${N_CONF} nova password neutron/nova_admin_password
96 }
97
98 # OVS specific configurations (if that's the one selected)
99 if [ "${NEUTRON_PLUGIN_NAME}" = "OpenVSwitch" ] ; then
100         # Various network config...
101         pkgos_read_config ${OVS_CONF} OVS tenant_network_type   neutron/tenant_network_type
102         pkgos_read_config ${OVS_CONF} OVS enable_tunneling      neutron/enable_tunneling
103         pkgos_read_config ${OVS_CONF} OVS tunnel_id_ranges      neutron/tunnel_id_ranges
104
105         read_nova_admin_credentials
106
107         # Guess values to put in the local_ip directive
108         IF=`LC_ALL=C route | grep default |awk -- '{ print $8 }'`
109         guessed_ip_addr=`LC_ALL=C ifconfig ${IF} | grep 'inet addr' | sed 's/.\+inet addr:\([0-9.]\+\).\+/\1/'`
110         if [ -z "${guessed_ip_addr}" ] ; then
111                 guessed_ip_addr=`LC_ALL=C ifconfig ${IF} | grep 'inet adr' | sed 's/.\+inet adr:\([0-9.]\+\).\+/\1/'`
112         fi
113         db_set neutron/local_ip ${guessed_ip_addr}
114         pkgos_read_config ${OVS_CONF} OVS local_ip neutron/local_ip
115 fi
116
117 exit 0