]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Now using /etc/default/neutron anymore, now reading the core_plugin directive in...
authorThomas Goirand <thomas@goirand.fr>
Thu, 8 Aug 2013 11:36:17 +0000 (13:36 +0200)
committerThomas Goirand <thomas@goirand.fr>
Thu, 8 Aug 2013 11:36:17 +0000 (13:36 +0200)
Rewritten-From: af50c0d16ab608dfb38be0fe99585042f95096d4

xenial/debian/neutron-common.config.in
xenial/debian/neutron-common.postinst.in
xenial/debian/neutron-common.templates
xenial/debian/neutron-server.init
xenial/debian/neutron.mydefault [deleted file]
xenial/debian/rules

index 67b52ffaed2767fd3e3552532610694253292cf7..5ace39f17d034eca8e3bdf39c767f8f85b066544 100644 (file)
@@ -7,26 +7,84 @@ set -e
 N_CONF=/etc/neutron/neutron.conf
 OVS_CONF=/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini
 
+neutron_core_plugin_to_plugin_name () {
+       case ${1} in
+       "neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2")
+               NEUTRON_PLUGIN_NAME=OpenVSwitch
+       ;;
+       "neutron.plugins.linuxbridge.lb_neutron_plugin.LinuxBridgePluginV2")
+               NEUTRON_PLUGIN_NAME=LinuxBridge
+       ;;
+       "neutron.plugins.ryu.ryu_neutron_plugin.RyuNeutronPluginV2")
+               NEUTRON_PLUGIN_NAME=RYU
+       ;;
+       "neutron.plugins.plumgrid.plumgrid_nos_plugin.plumgrid_plugin.NeutronPluginPLUMgridV2")
+               NEUTRON_PLUGIN_NAME=PLUMgrid
+       ;;
+       "neutron.plugins.brocade.NeutronPlugin.BrocadePluginV2")
+               NEUTRON_PLUGIN_NAME=Brocade
+       ;;
+       "neutron.plugins.hyperv.hyperv_neutron_plugin.HyperVNeutronPlugin")
+               NEUTRON_PLUGIN_NAME=Hyper-V
+       ;;
+       "neutron.plugins.bigswitch.plugin.NeutronRestProxyV2")
+               NEUTRON_PLUGIN_NAME=BigSwitch
+       ;;
+       "neutron.plugins.cisco.network_plugin.PluginV2")
+               NEUTRON_PLUGIN_NAME=Cisco
+       ;;
+       "neutron.plugins.nicira.NeutronPlugin.NvpPluginV2")
+               NEUTRON_PLUGIN_NAME=neutron.plugins.nicira.NeutronPlugin.NvpPluginV2
+       ;;
+       "neutron.plugins.midonet.plugin.MidonetPluginV2")
+               NEUTRON_PLUGIN_NAME=Midonet
+       ;;
+       "neutron.plugins.nec.nec_plugin.NECPluginV2")
+               NEUTRON_PLUGIN_NAME=Nec
+       ;;
+       "neutron.plugins.metaplugin.meta_neutron_plugin.MetaPluginV2")
+               NEUTRON_PLUGIN_NAME=MetaPlugin
+       ;;
+       "neutron.plugins.mlnx.mlnx_plugin.MellanoxEswitchPlugin")
+               NEUTRON_PLUGIN_NAME=Mellanox
+       ;;
+       *)
+               NEUTRON_PLUGIN_NAME="other"
+       ;;
+       esac
+}
+
 #PKGOS-INCLUDE#
 
 pkgos_var_user_group neutron
 chmod 755 /var/lib/neutron
 
 # Configure the SQL connection
-pkgos_dbc_read_conf -pkg neutron-common ${OVS_CONF} database connection neutron $@
+pkgos_dbc_read_conf -pkg neutron-common ${N_CONF} database connection neutron $@
 
 # Configure the keystone_authtoken
 pkgos_read_admin_creds ${N_CONF} keystone_authtoken neutron
 
 # Select which plugin to use
-pkgos_read_config -p high /etc/default/neutron-server NO_SECTION NEUTRON_plugin_path neutron/plugin-select
+if [ -r "${N_CONF}" ] ; then
+       pkgos_inifile get ${N_CONF} DEFAULT core_plugin
+       if [ -n "${RET}" ] ; then
+               NEUTRON_CORE_PLUGIN_CLASS=${RET}
+               neutron_core_plugin_to_plugin_name ${NEUTRON_CORE_PLUGIN_CLASS}
+               db_set neutron/plugin-select ${NEUTRON_PLUGIN_NAME}
+       fi
+fi
+db_input high neutron/plugin-select || true
+db_go
+db_get neutron/plugin-select
+NEUTRON_PLUGIN_NAME=${RET}
 
 # OVS specific configurations (if that's the one selected)
-if [ "${RET}" = "OpenVSwitch" ] ; then
+if [ "${NEUTRON_PLUGIN_NAME}" = "OpenVSwitch" ] ; then
        # Various network config...
-       pkgos_read_config ${OVS_CONF} OVS tenant_network_type   neutron-plugin-openvswitch/tenant_network_type
-       pkgos_read_config ${OVS_CONF} OVS enable_tunneling      neutron-plugin-openvswitch/enable_tunneling
-       pkgos_read_config ${OVS_CONF} OVS tunnel_id_ranges      neutron-plugin-openvswitch/tunnel_id_ranges
+       pkgos_read_config ${OVS_CONF} OVS tenant_network_type   neutron/tenant_network_type
+       pkgos_read_config ${OVS_CONF} OVS enable_tunneling      neutron/enable_tunneling
+       pkgos_read_config ${OVS_CONF} OVS tunnel_id_ranges      neutron/tunnel_id_ranges
 
        # Guess values to put in the local_ip directive
        IF=`LC_ALL=C route | grep default |awk -- '{ print $8 }'`
@@ -34,8 +92,8 @@ if [ "${RET}" = "OpenVSwitch" ] ; then
        if [ -z "${guessed_ip_addr}" ] ; then
                guessed_ip_addr=`LC_ALL=C ifconfig ${IF} | grep 'inet adr' | sed 's/.\+inet adr:\([0-9.]\+\).\+/\1/'`
        fi
-       db_set neutron-plugin-openvswitch/local_ip ${guessed_ip_addr}
-       pkgos_read_config ${OVS_CONF} OVS local_ip neutron-plugin-openvswitch/local_ip
+       db_set neutron/local_ip ${guessed_ip_addr}
+       pkgos_read_config ${OVS_CONF} OVS local_ip neutron/local_ip
 fi
 
 exit 0
index 921b93368253c93ba88547b6574f7014aa1ee078..94b694120eb1493fa7d530e35b97ff22cfd03d36 100644 (file)
@@ -54,8 +54,6 @@ neutron_core_plugin_class () {
        esac
 }
 
-
-
 if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ] ; then
        . /usr/share/debconf/confmodule
 
@@ -66,16 +64,10 @@ if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ] ; then
        pkgos_write_new_conf neutron neutron.conf
        chmod 0660 /etc/neutron/neutron.conf
 
-       # Maintain the /etc/default/neutron plugin type selection
-       # and fill-out the core_plugin class path in /etc/neutron/neutron.conf
-       # according to what's in /etc/default/neutron.
-       if [ ! -e /etc/default/neutron ] ; then
-               install -D -m 0664 /usr/share/neutron-common/neutron-default /etc/default/neutron
-       fi
+       # Sets the core_plugin directive according to the value in debconf
        db_get neutron/plugin-select
        NEUTRON_plugin=${RET}
        if [ -n "${RET}" ] ; then
-               pkgos_inifile -shinc set /etc/default/neutron NO_SECTION NEUTRON_plugin ${RET}
                neutron_core_plugin_class ${NEUTRON_plugin}
                pkgos_inifile set DEFAULT ${N_CONF} ${NEUTRON_PLUGIN_CLASS}
        fi
@@ -95,16 +87,16 @@ if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ] ; then
         fi
 
        if [ "${NEUTRON_plugin_path}" = "OpenVSwitch" ] ; then
-               db_get neutron-plugin-openvswitch/tenant_network_type
+               db_get neutron/tenant_network_type
                pkgos_inifile set ${OVS_CONF} OVS tenant_network_type "${RET}"
 
-               db_get neutron-plugin-openvswitch/enable_tunneling
+               db_get neutron/enable_tunneling
                pkgos_inifile set ${OVS_CONF} OVS enable_tunneling "${RET}"
 
-               db_get neutron-plugin-openvswitch/tunnel_id_ranges
+               db_get neutron/tunnel_id_ranges
                pkgos_inifile set ${OVS_CONF} OVS tunnel_id_ranges "${RET}"
 
-               db_get neutron-plugin-openvswitch/local_ip
+               db_get neutron/local_ip
                pkgos_inifile set ${OVS_CONF} OVS local_ip "${RET}"
        fi
        db_stop
index 524dc537b96b644b932637cb3cfeffc85bd2d31b..330bfd049b8f4d20f29556b4f671b8ca623d659b 100644 (file)
@@ -46,9 +46,9 @@ _Description: Neutron plugin:
 Template: neutron/configure_db
 Type: boolean 
 Default: true
-_Description: Set up a database for neutron-plugin-openvswitch?
- No database has been set up for neutron-plugin-openvswitch to use. Before
continuing, you should make sure you have the following information:
+_Description: Set up a database for Neutron?
+ No database has been set up for Neutron to use. Before continuing, you should
+ make sure you have the following information:
  .
   * the type of database that you want to use;
   * the database server hostname (that server must allow TCP connections from this
@@ -59,9 +59,9 @@ _Description: Set up a database for neutron-plugin-openvswitch?
  regular SQLite support.
  .
  You can change this setting later on by running "dpkg-reconfigure -plow
- neutron-plugin-openvswitch".
+ neutron".
 
-Template: neutron-plugin-openvswitch/tenant_network_type
+Template: neutron/tenant_network_type
 Type: select
 __Choices: local, gre, vlan, none
 Choices-C: local, gre, vlan, none
@@ -80,7 +80,7 @@ _Description: Type of network to allocate for tenant networks:
  choose "gre" and then configure "tunnel_id_ranges". Choose "none" to
  disable creation of tenant networks.
 
-Template: neutron-plugin-openvswitch/enable_tunneling
+Template: neutron/enable_tunneling
 Type: boolean
 Default: true
 _Description: Enable tunneling?
@@ -88,7 +88,7 @@ _Description: Enable tunneling?
  server and agents. This requires kernel support for OVS patch ports and
  GRE tunneling.
 
-Template: neutron-plugin-openvswitch/tunnel_id_ranges
+Template: neutron/tunnel_id_ranges
 Type: string
 Default: 1:1000
 _Description: Tunnel id ranges:
@@ -96,7 +96,7 @@ _Description: Tunnel id ranges:
  ranges of GRE tunnel IDs that are available for tenant network allocation
  if tenant_network_type is "gre".
 
-Template: neutron-plugin-openvswitch/local_ip
+Template: neutron/local_ip
 Type: string
 _Description: Local IP address of this hypervisor:
  Please enter the local IP address for this hypervisor.
index 35304c0f252a95893b791a4552dc10e517216b7c..e55452669795b729d1f72cfe9ea4ae2c533d52af 100644 (file)
@@ -26,6 +26,55 @@ DAEMON_ARGS="--config-file=/etc/neutron/neutron.conf --log-file=$LOGFILE"
 
 . /lib/lsb/init-functions
 
+### Guess the plugin name depending on the class of the plugin in /etc/neutron/neutron.conf ###
+neutron_core_plugin_to_plugin_name () {
+       case ${1} in
+       "neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2")
+               NEUTRON_PLUGIN_NAME=OpenVSwitch
+       ;;
+       "neutron.plugins.linuxbridge.lb_neutron_plugin.LinuxBridgePluginV2")
+               NEUTRON_PLUGIN_NAME=LinuxBridge
+       ;;
+       "neutron.plugins.ryu.ryu_neutron_plugin.RyuNeutronPluginV2")
+               NEUTRON_PLUGIN_NAME=RYU
+       ;;
+       "neutron.plugins.plumgrid.plumgrid_nos_plugin.plumgrid_plugin.NeutronPluginPLUMgridV2")
+               NEUTRON_PLUGIN_NAME=PLUMgrid
+       ;;
+       "neutron.plugins.brocade.NeutronPlugin.BrocadePluginV2")
+               NEUTRON_PLUGIN_NAME=Brocade
+       ;;
+       "neutron.plugins.hyperv.hyperv_neutron_plugin.HyperVNeutronPlugin")
+               NEUTRON_PLUGIN_NAME=Hyper-V
+       ;;
+       "neutron.plugins.bigswitch.plugin.NeutronRestProxyV2")
+               NEUTRON_PLUGIN_NAME=BigSwitch
+       ;;
+       "neutron.plugins.cisco.network_plugin.PluginV2")
+               NEUTRON_PLUGIN_NAME=Cisco
+       ;;
+       "neutron.plugins.nicira.NeutronPlugin.NvpPluginV2")
+               NEUTRON_PLUGIN_NAME=neutron.plugins.nicira.NeutronPlugin.NvpPluginV2
+       ;;
+       "neutron.plugins.midonet.plugin.MidonetPluginV2")
+               NEUTRON_PLUGIN_NAME=Midonet
+       ;;
+       "neutron.plugins.nec.nec_plugin.NECPluginV2")
+               NEUTRON_PLUGIN_NAME=Nec
+       ;;
+       "neutron.plugins.metaplugin.meta_neutron_plugin.MetaPluginV2")
+               NEUTRON_PLUGIN_NAME=MetaPlugin
+       ;;
+       "neutron.plugins.mlnx.mlnx_plugin.MellanoxEswitchPlugin")
+               NEUTRON_PLUGIN_NAME=Mellanox
+       ;;
+       *)
+               NEUTRON_PLUGIN_NAME="other"
+       ;;
+       esac
+}
+
+### Guess the path of the plugin .ini file depending on the plugin name ###
 neutron_plugin_ini_path () {
        PLUG_INI_BASE=/etc/neutron/plugins/
        case ${1} in
@@ -74,16 +123,27 @@ neutron_plugin_ini_path () {
        esac
 }
 
-if [ -r /etc/default/neutron ] ; then
-       . /etc/default/neutron
-       if [ -n "${NEUTRON_plugin}" ] ; then
-               neutron_plugin_ini_path ${NEUTRON_plugin}
-               if [ -n "${NEUTRON_PLUGIN_CONFIG}" ] ; then
-                       DAEMON_ARGS="${DAEMON_ARGS} --config-file=${NEUTRON_PLUGIN_CONFIG}"
-               fi
-       fi
+### Maintain the plugin selection so that we can load the corresponding .ini file ###
+if ! [ -r /etc/neutron/neutron.conf ] ; then
+       echo "Cloud not read /etc/neutron/neutron.conf: exiting"
+       exit 0
+fi
+
+CURRENT_PLUGIN=`grep "^[ \t]*core_plugin[ \t]*=[ \t]*[._a-zA-Z0-9]*\$" /etc/neutron/neutron.conf | sed -e 's/^[ \t]*core_plugin[ \t]*=[ \t]*//'`
+if [ -z "${CURRENT_PLUGIN}" ] ; then
+       echo "No core_plugin= value found: please set it and try again"
+       exit 0
+fi
+neutron_core_plugin_to_plugin_name ${CURRENT_PLUGIN}
+neutron_plugin_ini_path ${NEUTRON_PLUGIN_NAME}
+if [ -z "${NEUTRON_PLUGIN_CONFIG}" ] ; then
+       echo "Plugin not recognized: please edit /etc/init.d/neutron-server to select the correct .ini file to load for your plugin"
+else
+       DAEMON_ARGS="${DAEMON_ARGS} --config-file=${NEUTRON_PLUGIN_CONFIG}"
+       DESC="${DESC} with ${NEUTRON_PLUGIN_NAME} plugin"
 fi
 
+### Neutron folders creation ###
 make_neutron_folder () {
        if [ ! -e ${1} ] ; then
                mkdir -p ${1}
@@ -99,6 +159,7 @@ for i in /var/run/neutron /var/log/neutron /var/lib/neutron/tmp ; do
 done
 export TMPDIR=/var/lib/neutron/tmp
 
+### Standard init script start/stop/etc. stuff ###
 do_start () {
        start-stop-daemon --start --quiet --background --chuid neutron:neutron --chdir $DAEMON_DIR --make-pidfile --pidfile $PIDFILE --startas $DAEMON --test > /dev/null \
                || return 1
diff --git a/xenial/debian/neutron.mydefault b/xenial/debian/neutron.mydefault
deleted file mode 100644 (file)
index 8493de5..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-# Default configuration file for Neutron. Currently only there to be able to
-# select which plugin to use, and configure neutron-server accordingly. You
-# can edit the file if you don't break its (shell script) syntax, or use:
-#  dpkg-reconfigure -plow neutron-server
-
-# Select the plugin to load. Possible values are:
-# OpenVSwitch
-# LinuxBridge
-# RYU
-# PLUMgrid
-# Brocade
-# Hyper-V
-# BigSwitch
-# Cisco
-# Nicira
-# Midonet
-# Nec
-# MetaPlugin
-# Mellanox
-#
-# If more plugins were to come, then simply editing this file is not enough,
-# the debconf template will need to be edited to add the new value,
-# debian/neutron-server.init, debian/neutron-server.postinst.in will also
-# need edition, otherwise this will break on upgrades.
-
-NEUTRON_plugin=OpenVSwitch
index 753d6dc63701255abc3d724f938b9d3051b2acf6..e23c6b676d73fdb0bdd8476a2eea11f43a4997d6 100755 (executable)
@@ -37,9 +37,6 @@ override_dh_install:
        install -D -m 0640 etc/metadata_agent.ini                                       $(CURDIR)/debian/neutron-metadata-agent/usr/share/neutron-metadata-agent/metadata_agent.ini
        sed -i -e 's|^# nova_metadata_ip = 127.0.0.1|nova_metadata_ip = 127.0.0.1|'     $(CURDIR)/debian/neutron-metadata-agent/usr/share/neutron-metadata-agent/metadata_agent.ini
 
-       # Install the default file
-       install -D -m 0640 debian/neutron.mydefault $(CURDIR)/debian/neutron-common/usr/share/neutron-common/neutron-default
-
        # Move the OVS config file, since we use debconf for it
        rm $(CURDIR)/debian/neutron-common/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini
        install -D -m 0640 etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini $(CURDIR)/debian/neutron-common/usr/share/neutron-common/ovs_neutron_plugin.ini