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 }'`
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
esac
}
-
-
if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ] ; then
. /usr/share/debconf/confmodule
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
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
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
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
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?
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:
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.
. /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
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}
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
+++ /dev/null
-# 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
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