Add Neutron 7.0.0 for Ubuntu 14.04
[openstack-build/neutron-build.git] / trusty / 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         *)
56                 NEUTRON_PLUGIN_NAME="other"
57         ;;
58         esac
59 }
60
61 #PKGOS-INCLUDE#
62
63 pkgos_var_user_group neutron
64 chmod 755 /var/lib/neutron
65
66 # Configure the SQL connection
67 pkgos_dbc_read_conf -pkg neutron-common ${N_CONF} database connection neutron $@
68 pkgos_rabbit_read_conf ${N_CONF} oslo_messaging_rabbit neutron
69
70 # Configure the keystone_authtoken
71 pkgos_read_admin_creds ${N_CONF} keystone_authtoken neutron
72
73 # Select which plugin to use
74 if [ -r "${N_CONF}" ] ; then
75         pkgos_inifile get ${N_CONF} DEFAULT core_plugin
76         if [ -n "${RET}" ] ; then
77                 NEUTRON_CORE_PLUGIN_CLASS=${RET}
78                 neutron_core_plugin_to_plugin_name ${NEUTRON_CORE_PLUGIN_CLASS}
79                 db_set neutron/plugin-select ${NEUTRON_PLUGIN_NAME}
80         fi
81 fi
82 db_input high neutron/plugin-select || true
83 db_go
84 db_get neutron/plugin-select
85 NEUTRON_PLUGIN_NAME=${RET}
86
87 read_nova_admin_credentials () {
88         pkgos_read_config -p high ${N_CONF} DEFAULT nova_url neutron/nova_url
89         pkgos_read_config -p high ${N_CONF} DEFAULT nova_region_name neutron/nova_region
90         pkgos_read_config -p medium ${N_CONF} DEFAULT nova_admin_tenant_id neutron/nova_admin_tenant_id
91         pkgos_read_config -p medium ${N_CONF} DEFAULT nova_admin_username neutron/nova_admin_username
92         pkgos_read_config -p high ${N_CONF} DEFAULT nova_admin_password neutron/nova_admin_password
93 }
94
95 # OVS specific configurations (if that's the one selected)
96 if [ "${NEUTRON_PLUGIN_NAME}" = "OpenVSwitch" ] ; then
97         # Various network config...
98         pkgos_read_config ${OVS_CONF} OVS tenant_network_type   neutron/tenant_network_type
99         pkgos_read_config ${OVS_CONF} OVS enable_tunneling      neutron/enable_tunneling
100         pkgos_read_config ${OVS_CONF} OVS tunnel_id_ranges      neutron/tunnel_id_ranges
101
102         read_nova_admin_credentials
103
104         # Guess values to put in the local_ip directive
105         IF=`LC_ALL=C route | grep default |awk -- '{ print $8 }'`
106         guessed_ip_addr=`LC_ALL=C ifconfig ${IF} | grep 'inet addr' | sed 's/.\+inet addr:\([0-9.]\+\).\+/\1/'`
107         if [ -z "${guessed_ip_addr}" ] ; then
108                 guessed_ip_addr=`LC_ALL=C ifconfig ${IF} | grep 'inet adr' | sed 's/.\+inet adr:\([0-9.]\+\).\+/\1/'`
109         fi
110         db_set neutron/local_ip ${guessed_ip_addr}
111         pkgos_read_config ${OVS_CONF} OVS local_ip neutron/local_ip
112 fi
113
114 exit 0