]> review.fuel-infra Code Review - openstack-build/neutron-build.git/blob - trusty/debian/neutron-common.postinst.in
c9010ea71e2cc7cb8985d102c26d70409484b2f1
[openstack-build/neutron-build.git] / trusty / debian / neutron-common.postinst.in
1 #!/bin/sh
2
3 set -e
4
5 N_CONF=/etc/neutron/neutron.conf
6 OVS_CONF=/etc/neutron/plugins/ml2/openvswitch_agent.ini
7
8 #PKGOS-INCLUDE#
9
10 neutron_core_plugin_class () {
11         case ${1} in
12         "OpenVSwitch")
13                 NEUTRON_PLUGIN_CLASS=neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2
14         ;;
15         "ml2")
16                 NEUTRON_PLUGIN_CLASS=neutron.plugins.ml2.plugin.Ml2Plugin
17         ;;
18         "LinuxBridge")
19                 NEUTRON_PLUGIN_CLASS=neutron.plugins.linuxbridge.lb_neutron_plugin.LinuxBridgePluginV2
20         ;;
21         "RYU")
22                 NEUTRON_PLUGIN_CLASS=neutron.plugins.ryu.ryu_neutron_plugin.RyuNeutronPluginV2
23         ;;
24         "PLUMgrid")
25                 NEUTRON_PLUGIN_CLASS=neutron.plugins.plumgrid.plumgrid_nos_plugin.plumgrid_plugin.NeutronPluginPLUMgridV2
26         ;;
27         "Brocade")
28                 NEUTRON_PLUGIN_CLASS=neutron.plugins.brocade.NeutronPlugin.BrocadePluginV2
29         ;;
30         "Hyper-V")
31                 NEUTRON_PLUGIN_CLASS=neutron.plugins.hyperv.hyperv_neutron_plugin.HyperVNeutronPlugin
32         ;;
33         "BigSwitch")
34                 NEUTRON_PLUGIN_CLASS=neutron.plugins.bigswitch.plugin.NeutronRestProxyV2
35         ;;
36         "Cisco")
37                 NEUTRON_PLUGIN_CLASS=neutron.plugins.cisco.network_plugin.PluginV2
38         ;;
39         "Nicira")
40                 NEUTRON_PLUGIN_CLASS=neutron.plugins.nicira.NeutronPlugin.NvpPluginV2
41         ;;
42         "Midonet")
43                 NEUTRON_PLUGIN_CLASS=neutron.plugins.midonet.plugin.MidonetPluginV2
44         ;;
45         "Nec")
46                 NEUTRON_PLUGIN_CLASS=neutron.plugins.nec.nec_plugin.NECPluginV2
47         ;;
48         "MetaPlugin")
49                 NEUTRON_PLUGIN_CLASS=neutron.plugins.metaplugin.meta_neutron_plugin.MetaPluginV2
50         ;;
51         "Mellanox")
52                 NEUTRON_PLUGIN_CLASS=neutron.plugins.mlnx.mlnx_plugin.MellanoxEswitchPlugin
53         ;;
54         *)
55                 NEUTRON_PLUGIN_CLASS=""
56         ;;
57         esac
58 }
59
60 if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ] ; then
61         . /usr/share/debconf/confmodule
62
63         pkgos_var_user_group neutron
64         chmod 755 /var/lib/neutron
65
66         pkgos_write_new_conf neutron api-paste.ini
67         pkgos_write_new_conf neutron neutron.conf
68         chmod 0660 /etc/neutron/neutron.conf
69
70         # Sets the core_plugin directive according to the value in debconf
71         db_get neutron/plugin-select
72         NEUTRON_plugin=${RET}
73         if [ -n "${RET}" ] ; then
74                 neutron_core_plugin_class ${NEUTRON_plugin}
75                 pkgos_inifile set ${N_CONF} DEFAULT core_plugin ${NEUTRON_PLUGIN_CLASS}
76         fi
77
78         # Write the neutron RabbitMQ credentials
79         pkgos_rabbit_write_conf ${N_CONF} oslo_messaging_rabbit neutron
80
81         # Set the keystone_authtoken directive
82         pkgos_write_admin_creds ${N_CONF} keystone_authtoken neutron
83
84         # Set the sql_connection directive
85         pkgos_dbc_postinst --suite neutron ${N_CONF} database connection neutron $@
86
87         db_get neutron/configure_db
88         if [ "$RET" = "true" ] ; then
89                 # Migrating to latest release of the db
90                 neutron-db-manage --config-file /etc/neutron/neutron.conf upgrade head
91         fi
92
93         # Maintain the OVS config
94         if [ ! -e ${OVS_CONF} ] ; then
95                 install -D -m 0640 -o neutron -g neutron /usr/share/neutron-common/openvswitch_agent.ini ${OVS_CONF}
96         fi
97
98         if [ "${NEUTRON_plugin_path}" = "OpenVSwitch" ] ; then
99                 db_get neutron/tenant_network_type
100                 pkgos_inifile set ${OVS_CONF} OVS tenant_network_type "${RET}"
101
102                 db_get neutron/enable_tunneling
103                 pkgos_inifile set ${OVS_CONF} OVS enable_tunneling "${RET}"
104
105                 db_get neutron/tunnel_id_ranges
106                 pkgos_inifile set ${OVS_CONF} OVS tunnel_id_ranges "${RET}"
107
108                 db_get neutron/local_ip
109                 pkgos_inifile set ${OVS_CONF} OVS local_ip "${RET}"
110         fi
111
112         db_stop
113
114         chown -R neutron:adm /var/log/neutron/
115         chmod 0700 /etc/neutron
116         chmod 0750 /var/log/neutron/
117         chown root:root /etc/neutron/rootwrap.conf
118         chown root:root /etc/neutron/rootwrap.d
119         chmod 0755 /etc/neutron/rootwrap.d
120
121         # The /var/lib/neutron/dhcp needs to be readable from the nobody user.
122         chmod 755 /var/lib/neutron
123         mkdir -p /var/lib/neutron/dhcp
124         chown neutron:neutron /var/lib/neutron/dhcp
125         chmod 755 /var/lib/neutron/dhcp
126
127         if [ -f /etc/sudoers.d/neutron_sudoers ] ; then
128                 chmod 0440 /etc/sudoers.d/neutron_sudoers
129         fi
130 fi
131
132 #DEBHELPER#