[openstack-quantum] Update to official essex rc1 milestone

Robert A. Kukura rkukura at fedoraproject.org
Wed Mar 21 04:46:17 UTC 2012


commit 7bbf28c301e4961a900abf3d34ad5b1c3beeb4af
Author: Bob Kukura <rkukura at redhat.com>
Date:   Wed Mar 21 00:45:52 2012 -0400

    Update to official essex rc1 milestone
    
    - Add quantum-server-setup and quantum-node-setup scripts
    - Use hand-coded agent executables rather than easy-install scripts
    - Make plugin config files mode 640 and group quantum to protect passwords

 .gitignore             |    2 +-
 openstack-quantum.spec |   46 ++++--
 quantum-config-set     |   24 +++
 quantum-node-setup     |  221 +++++++++++++++++++++++++++
 quantum-server-setup   |  391 ++++++++++++++++++++++++++++++++++++++++++++++++
 sources                |    2 +-
 6 files changed, 668 insertions(+), 18 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index a1d46de..50d14d8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-/quantum-2012.1~rc1~20120316.764.tar.gz
+/quantum-2012.1~rc1.tar.gz
diff --git a/openstack-quantum.spec b/openstack-quantum.spec
index 095ab12..8bb174a 100644
--- a/openstack-quantum.spec
+++ b/openstack-quantum.spec
@@ -1,23 +1,22 @@
 #
-# This is 2012.1 essex-4 milestone
+# This is 2012.1 essex rc1 milestone
 #
-%global release_name essex
-%global release_letter e
-%global milestone 4
 
 Name:		openstack-quantum
 Version:	2012.1
-Release:	0.5.%{release_letter}%{milestone}%{?dist}
+Release:	0.6.rc1%{?dist}
 Summary:	Virtual network service for OpenStack (quantum)
 
 Group:		Applications/System
 License:	ASL 2.0
 URL:		http://launchpad.net/quantum/
 
-#Source0:	http://launchpad.net/quantum/%%{release_name}/%%{release_name}-%%{milestone}/+download/quantum-%%{version}~%%{release_letter}%%{milestone}.tar.gz
-Source0:	http://quantum.openstack.org/tarballs/quantum-2012.1~rc1~20120316.764.tar.gz
+Source0:	http://launchpad.net/quantum/essex/essex-rc1/+download/quantum-2012.1~rc1.tar.gz
 Source1:	quantum.logrotate
 Source2:	quantum-sudoers
+Source3:	quantum-config-set
+Source4:	quantum-server-setup
+Source5:	quantum-node-setup
 
 Source10:	quantum-server.service
 Source11:	quantum-linuxbridge-agent.service
@@ -163,9 +162,6 @@ find quantum -name \*.py -exec sed -i '/\/usr\/bin\/env python/d' {} \;
 chmod 644 quantum/plugins/cisco/README
 dos2unix quantum/plugins/cisco/README
 
-# remove runtime dependency only needed for tests
-sed -i '/webtest/d' setup.py
-
 
 %build
 %{__python} setup.py build
@@ -184,13 +180,17 @@ rm -f %{buildroot}%{python_sitelib}/quantum/plugins/*/run_tests.*
 rm %{buildroot}/usr/etc/quantum/quantum.conf.test
 rm %{buildroot}/usr/etc/init.d/quantum-server
 
-# Install execs
+# Install execs (using hand-coded rather than generated versions)
 install -p -D -m 755 bin/quantum-server %{buildroot}%{_bindir}/quantum-server
+install -p -D -m 755 bin/quantum-linuxbridge-agent %{buildroot}%{_bindir}/quantum-linuxbridge-agent
+install -p -D -m 755 bin/quantum-openvswitch-agent %{buildroot}%{_bindir}/quantum-openvswitch-agent
+install -p -D -m 755 bin/quantum-ryu-agent %{buildroot}%{_bindir}/quantum-ryu-agent
 install -p -D -m 755 bin/quantum-rootwrap %{buildroot}%{_bindir}/quantum-rootwrap
 
 # Move config files to proper location
 install -d -m 755 %{buildroot}%{_sysconfdir}/quantum
 mv %{buildroot}/usr/etc/quantum/* %{buildroot}%{_sysconfdir}/quantum
+chmod 640  %{buildroot}%{_sysconfdir}/quantum/plugins/*/*.ini
 
 # Configure plugin agents to use quantum-rootwrap
 for f in %{buildroot}%{_sysconfdir}/quantum/plugins/*/*.ini; do
@@ -213,6 +213,11 @@ install -p -D -m 644 %{SOURCE13} %{buildroot}%{_unitdir}/quantum-ryu-agent.servi
 install -d -m 755 %{buildroot}%{_sharedstatedir}/quantum
 install -d -m 755 %{buildroot}%{_localstatedir}/log/quantum
 
+# Install setup helper scripts
+install -p -D -m 755 %{SOURCE3} %{buildroot}%{_bindir}/quantum-config-set
+install -p -D -m 755 %{SOURCE4} %{buildroot}%{_bindir}/quantum-server-setup
+install -p -D -m 755 %{SOURCE5} %{buildroot}%{_bindir}/quantum-node-setup
+
 
 %pre
 getent group quantum >/dev/null || groupadd -r quantum --gid 164
@@ -298,6 +303,9 @@ fi
 %doc README
 %{_bindir}/quantum-server
 %{_bindir}/quantum-rootwrap
+%{_bindir}/quantum-config-set
+%{_bindir}/quantum-server-setup
+%{_bindir}/quantum-node-setup
 %{_unitdir}/quantum-server.service
 %dir %{_sysconfdir}/quantum
 %config(noreplace) %{_sysconfdir}/quantum/quantum.conf
@@ -347,7 +355,7 @@ fi
 %{python_sitelib}/quantum/extensions/_qos_view.py*
 %{python_sitelib}/quantum/plugins/cisco
 %dir %{_sysconfdir}/quantum/plugins/cisco
-%config(noreplace) %{_sysconfdir}/quantum/plugins/cisco/*.ini
+%config(noreplace) %attr(-, root, quantum) %{_sysconfdir}/quantum/plugins/cisco/*.ini
 
 
 %files -n openstack-quantum-linuxbridge
@@ -358,7 +366,7 @@ fi
 %{python_sitelib}/quantum/plugins/linuxbridge
 %{python_sitelib}/quantum/rootwrap/linuxbridge-agent.py*
 %dir %{_sysconfdir}/quantum/plugins/linuxbridge
-%config(noreplace) %{_sysconfdir}/quantum/plugins/linuxbridge/*.ini
+%config(noreplace) %attr(-, root, quantum) %{_sysconfdir}/quantum/plugins/linuxbridge/*.ini
 
 
 %files -n openstack-quantum-nicira
@@ -366,7 +374,7 @@ fi
 %doc quantum/plugins/nicira/nicira_nvp_plugin/README
 %{python_sitelib}/quantum/plugins/nicira
 %dir %{_sysconfdir}/quantum/plugins/nicira
-%config(noreplace) %{_sysconfdir}/quantum/plugins/nicira/*.ini
+%config(noreplace) %attr(-, root, quantum) %{_sysconfdir}/quantum/plugins/nicira/*.ini
 
 
 %files -n openstack-quantum-openvswitch
@@ -377,7 +385,7 @@ fi
 %{python_sitelib}/quantum/plugins/openvswitch
 %{python_sitelib}/quantum/rootwrap/openvswitch-agent.py*
 %dir %{_sysconfdir}/quantum/plugins/openvswitch
-%config(noreplace) %{_sysconfdir}/quantum/plugins/openvswitch/*.ini
+%config(noreplace) %attr(-, root, quantum) %{_sysconfdir}/quantum/plugins/openvswitch/*.ini
 
 
 %files -n openstack-quantum-ryu
@@ -388,10 +396,16 @@ fi
 %{python_sitelib}/quantum/plugins/ryu
 %{python_sitelib}/quantum/rootwrap/ryu-agent.py*
 %dir %{_sysconfdir}/quantum/plugins/ryu
-%config(noreplace) %{_sysconfdir}/quantum/plugins/ryu/*.ini
+%config(noreplace) %attr(-, root, quantum) %{_sysconfdir}/quantum/plugins/ryu/*.ini
 
 
 %changelog
+* Wed Mar 21 2012 Robert Kukura <rkukura at redhat.com> - 2012.1-0.6.rc1
+- Update to official essex rc1 milestone
+- Add quantum-server-setup and quantum-node-setup scripts
+- Use hand-coded agent executables rather than easy-install scripts
+- Make plugin config files mode 640 and group quantum to protect passwords
+
 * Mon Mar 19 2012 Robert Kukura <rkukura at redhat.com> - 2012.1-0.5.e4
 - Update to essex possible RC1 tarball
 - Remove patches incorporated upstream
diff --git a/quantum-config-set b/quantum-config-set
new file mode 100644
index 0000000..2b97fb6
--- /dev/null
+++ b/quantum-config-set
@@ -0,0 +1,24 @@
+#!/usr/bin/python
+
+import iniparse
+import sys
+
+try:
+  cfgfile=sys.argv[1]
+  section=sys.argv[2]
+  parameter=sys.argv[3]
+  value=sys.argv[4]
+except:
+  print sys.argv[0]+" config_file section parameter value"
+  sys.exit(1)
+
+conf=iniparse.ConfigParser()
+conf.read(cfgfile)
+if not conf.has_section(section):
+    conf.add_section(section)
+conf.set(section, parameter, value)
+
+fp=open(cfgfile,"w")
+conf.write(fp)
+fp.close()
+
diff --git a/quantum-node-setup b/quantum-node-setup
new file mode 100644
index 0000000..ec7e2c3
--- /dev/null
+++ b/quantum-node-setup
@@ -0,0 +1,221 @@
+#!/bin/bash
+#
+# Copyright (C) 2012, Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+
+# The script supports the plugins below
+declare -a SUPPORTED_PLUGINS=(cisco linuxbridge nicira openvswitch ryu)
+
+#
+# Print --help output and exit.
+#
+usage() {
+
+cat << EOF
+The helper script will install the necessary support for the selected plugin.
+
+Usage: quantum-node-setup [options]
+Options:
+	--help        | -h
+		Print usage information.
+        --qpw <pw>    | -q <pw>
+                Specify the password for the 'quantum' MySQL user that quantum will
+                use to connect to the 'quantum' MySQL database.  By default,
+                the password 'quantum' will be used.
+	--yes         | -y
+		In cases where the script would normally ask for confirmation
+		before doing something, such as installing mysql-server,
+		just assume yes.  This is useful if you want to run the script
+		non-interactively.
+        --user        | -u
+		The quantum user. 
+        --plugin      | -p
+                The quantum plugin. Supported plugins:-
+                    ${SUPPORTED_PLUGINS[*]}
+        --dbhost        | -d
+		The quantum database host. 
+EOF
+
+	exit 0
+}
+
+is_valid_plugin() {
+	local i=
+	for i in "${SUPPORTED_PLUGINS[@]}"; do
+		if [ "$i" == "$1" ]; then
+			return 0 
+		fi
+	done
+	return 1
+}
+
+QUANTUM_USER=quantum
+MYSQL_Q_PW=quantum
+CISCO_CONF=/etc/quantum/plugins/cisco/db_conn.ini
+LB_CONF=/etc/quantum/plugins/linuxbridge/linuxbridge_conf.ini
+OVS_CONF=/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini
+# Nova specific
+NOVA_CONF=/etc/nova/nova.conf
+
+while [ $# -gt 0 ]
+do
+	case "$1" in
+		-h|--help)
+			usage
+			;;
+		-q|--qpw)
+			shift
+			MYSQL_Q_PW==${1}
+			;;
+		-y|--yes)
+			ASSUME_YES="yes"
+			;;
+                -u|--user)
+                        shift
+                        QUANTUM_USER=${1}
+                        ;;
+                -p|--plugin)
+                        shift
+                        QUANTUM_PLUGIN=${1}
+                        ;;
+                -d|--dbhost)
+                        shift
+                        QUANTUM_HOST=${1}
+                        ;;
+		*)
+			# ignore
+			shift
+			;;
+	esac
+	shift
+done
+
+# if the plugin is not defined
+if [ -z ${QUANTUM_PLUGIN} ] ; then
+        echo "Please select a plugin from: ${SUPPORTED_PLUGINS[*]}"
+        echo "Choice:"
+        read QUANTUM_PLUGIN
+fi
+
+# check that the plugin is valid
+is_valid_plugin ${QUANTUM_PLUGIN}
+if [ $? -ne 0 ]; then
+        echo "Plugin '${QUANTUM_PLUGIN}' not supported. Supported plugins:-"
+        echo "    ${SUPPORTED_PLUGINS[*]}"
+        exit 0
+fi
+
+echo "Quantum plugin: ${QUANTUM_PLUGIN}"
+
+if ! [ -e "/etc/quantum/plugins/${QUANTUM_PLUGIN}" ]; then
+	echo "Please install the ${QUANTUM_PLUGIN} quantum plugin"
+        exit 0
+fi
+
+#if the database hostname and is not defined and is required
+if [ -z ${QUANTUM_HOST} ] ; then
+	case "${QUANTUM_PLUGIN}" in
+	"cisco"|"linuxbridge"|"openvswitch")
+		echo "Please enter the Quantum database hostname:"
+		read QUANTUM_HOST
+		;;
+	esac
+fi
+
+case "${QUANTUM_PLUGIN}" in
+"cisco")
+        quantum-config-set ${CISCO_CONF} DATABASE user ${QUANTUM_USER}
+        quantum-config-set ${CISCO_CONF} DATABASE pass ${MYSQL_Q_PW}
+        quantum-config-set ${CISCO_CONF} DATABASE host ${QUANTUM_HOST}
+        SCHEDULER_DRIVER=quantum.plugins.cisco.nova.quantum_port_aware_scheduler.QuantumPortAwareScheduler
+        LIBVIRT_VIF_DRIVER=quantum.plugins.cisco.nova.vifdirect.Libvirt802dot1QbhDriver
+        LIBVIRT_VIF_TYPE=802.1Qbh
+;;
+
+"linuxbridge")
+	quantum-config-set ${LB_CONF} DATABASE connection mysql
+        quantum-config-set ${LB_CONF} DATABASE user ${QUANTUM_USER}
+        quantum-config-set ${LB_CONF} DATABASE pass ${MYSQL_Q_PW}
+	quantum-config-set ${LB_CONF} DATABASE host ${QUANTUM_HOST}
+        LIBVIRT_VIF_TYPE=ethernet
+        LIBVIRT_VIF_DRIVER=nova.virt.libvirt.vif.QuantumLinuxBridgeVIFDriver
+        LINUX_INTERFACE_DRIVER=nova.network.linux_net.QuantumLinuxBridgeInterfaceDriver
+;;
+
+"nicira")
+	echo "Complete!"
+        exit 0;
+;;
+
+"openvswitch")
+        if ! rpm -q openvswitch > /dev/null
+        then
+                echo "Please install openvswitch"
+                exit 0
+        fi
+        quantum-config-set ${OVS_CONF} DATABASE sql_connection mysql://${QUANTUM_USER}:${MYSQL_Q_PW}@${QUANTUM_HOST}/ovs_quantum
+        LIBVIRT_VIF_TYPE=ethernet
+        LIBVIRT_VIF_DRIVER=nova.virt.libvirt.vif.LibvirtOpenVswitchDriver
+        LINUX_INTERFACE_DRIVER=nova.network.linux_net.LinuxOVSInterfaceDriver
+;;
+
+"ryu")
+	echo "Complete!"
+        exit 0;
+;;
+
+esac
+
+echo "Would you like to update the nova configuration files? (y/n): "
+read response
+case "$response" in
+y|Y)
+        ;;
+*)
+        echo "Complete!"
+        exit 0
+esac
+
+# If OpenStack is installed then configure nova.conf
+if ! [ -e "${NOVA_CONF}" ]; then
+        echo "Please install OpenStack compute and then set the value in /etc/nova/nova.conf DEFAULT section"
+        echo "network_manager=nova.network.quantum.manager.QuantumManager"
+        echo "quantum_connection_host=${QUANTUM_HOST}"
+        echo "quantum_connection_port 9696"
+        echo "quantum_use_dhcp True"
+        echo "scheduler_driver ${SCHEDULER_DRIVER}"
+        echo "libvirt_vif_driver ${LIBVIRT_VIF_DRIVER}"
+        echo "libvirt_vif_type ${LIBVIRT_VIF_TYPE}"
+        echo "linuxnet_interface_driver ${LINUX_INTERFACE_DRIVER}"
+else
+        openstack-config-set ${NOVA_CONF} DEFAULT network_manager nova.network.quantum.manager.QuantumManager
+        openstack-config-set ${NOVA_CONF} DEFAULT quantum_connection_host ${QUANTUM_HOST}
+        openstack-config-set ${NOVA_CONF} DEFAULT quantum_connection_port 9696
+        openstack-config-set ${NOVA_CONF} DEFAULT quantum_use_dhcp True
+	if [ ${SCHEDULER_DRIVER} ]; then
+	        openstack-config-set ${NOVA_CONF} DEFAULT scheduler_driver ${SCHEDULER_DRIVER}
+	fi
+        if [ ${LIBVIRT_VIF_DRIVER} ]; then
+	        openstack-config-set ${NOVA_CONF} DEFAULT libvirt_vif_driver ${LIBVIRT_VIF_DRIVER}
+	fi
+        if [ ${LIBVIRT_VIF_TYPE} ]; then
+        	openstack-config-set ${NOVA_CONF} DEFAULT libvirt_vif_type ${LIBVIRT_VIF_TYPE}
+	fi
+        if [ ${LINUX_INTERFACE_DRIVER} ]; then
+	        openstack-config-set ${NOVA_CONF} DEFAULT linuxnet_interface_driver ${LINUX_INTERFACE_DRIVER}
+	fi
+fi
+
+echo "Configuration updates complete!"
diff --git a/quantum-server-setup b/quantum-server-setup
new file mode 100644
index 0000000..895d9b2
--- /dev/null
+++ b/quantum-server-setup
@@ -0,0 +1,391 @@
+#!/bin/bash
+#
+# Copyright (C) 2012, Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+
+# The script supports the plugins below
+declare -a SUPPORTED_PLUGINS=(cisco linuxbridge nicira openvswitch ryu)
+
+#
+# Print --help output and exit.
+#
+usage() {
+
+cat << EOF
+The helper script will install the necessary database support for the selected plugin.
+Please note that some plugins do not require database support. These are addressed in the script.
+The setup of MySQL with a multi-server OpenStack installation is outside of the scope of 
+this simple helper script.
+
+Usage: quantum-server-setup [options]
+Options:
+	--help        | -h
+		Print usage information.
+        --qpw <pw>    | -q <pw>
+                Specify the password for the 'quantum' MySQL user that quantum will
+                use to connect to the 'quantum' MySQL database.  By default,
+                the password 'quantum' will be used.
+
+	--rootpw <pw> | -r <pw>
+		Specify the root MySQL password.  If the script installs
+		the MySQL server, it will set the root password to this value
+		instead of prompting for a password.  If the MySQL server is
+		already installed, this password will be used to connect to the
+		database instead of having to prompt for it.
+	--yes         | -y
+		In cases where the script would normally ask for confirmation
+		before doing something, such as installing mysql-server,
+		just assume yes.  This is useful if you want to run the script
+		non-interactively.
+        --user        | -u
+		The quantum user. 
+        --plugin      | -p
+                The quantum plugin. Supported plugins:-
+                    ${SUPPORTED_PLUGINS[*]}
+EOF
+
+	exit 0
+}
+
+install_mysql_server() {
+	if [ -z "${ASSUME_YES}" ] ; then
+		yum install mysql-server
+	else
+		yum install -y mysql-server
+	fi
+}
+
+start_mysql_server() {
+	systemctl start mysqld.service
+}
+
+is_valid_plugin() {
+	local i=
+	for i in "${SUPPORTED_PLUGINS[@]}"; do
+		if [ "$i" == "$1" ]; then
+			return 0 
+		fi
+	done
+	return 1
+}
+
+ASSUME_YES=""
+QUANTUM_USER=quantum
+MYSQL_Q_PW=quantum
+CISCO_CONF=/etc/quantum/plugins/cisco/db_conn.ini
+Q_CONF=/etc/quantum/plugins.ini
+LB_CONF=/etc/quantum/plugins/linuxbridge/linuxbridge_conf.ini
+OVS_CONF=/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini
+
+# Nova specific
+NOVA_CONF=/etc/nova/nova.conf
+SCHEDULER_DRIVER=""
+LIBVIRT_VIF_DRIVER=""
+LIBVIRT_VIF_TYPE=""
+LINUX_INTERFACE_DRIVER=""
+
+while [ $# -gt 0 ]
+do
+	case "$1" in
+		-h|--help)
+			usage
+			;;
+		-q|--qpw)
+			shift
+			MYSQL_Q_PW==${1}
+			;;
+		-r|--rootpw)
+			shift
+			MYSQL_ROOT_PW=${1}
+			;;
+		-y|--yes)
+			ASSUME_YES="yes"
+			;;
+                -u|--user)
+                        shift
+                        QUANTUM_USER=${1}
+                        ;;
+                -p|--plugin)
+                        shift
+                        QUANTUM_PLUGIN=${1}
+                        ;;
+		*)
+			# ignore
+			shift
+			;;
+	esac
+	shift
+done
+
+# if the plugin is not defined
+if [ -z ${QUANTUM_PLUGIN} ] ; then
+        echo "Please select a plugin from: ${SUPPORTED_PLUGINS[*]}"
+	echo "Choice:"
+        read QUANTUM_PLUGIN
+fi
+
+# check that the plugin is valid
+is_valid_plugin ${QUANTUM_PLUGIN}
+if [ $? -ne 0 ]; then
+	echo "Plugin '${QUANTUM_PLUGIN}' not supported. Supported plugins:-"
+	echo "    ${SUPPORTED_PLUGINS[*]}"
+	exit 0
+fi
+
+echo "Quantum plugin: ${QUANTUM_PLUGIN}"
+
+if ! [ -e "${Q_CONF}" ]; then
+	echo "Please install the quantum package"
+	exit 0
+fi
+
+if ! [ -e "/etc/quantum/plugins/${QUANTUM_PLUGIN}" ]; then
+	echo "Please install the ${QUANTUM_PLUGIN} quantum plugin"
+        exit 0
+fi
+
+case "${QUANTUM_PLUGIN}" in
+"cisco")
+	DB_NAME="quantum_l2network"
+	quantum-config-set ${Q_CONF} PLUGIN provider quantum.plugins.cisco.l2network_plugin.L2Network
+;;
+
+"linuxbridge")
+	DB_NAME="quantum_linux_bridge"
+	quantum-config-set ${Q_CONF} PLUGIN provider quantum.plugins.linuxbridge.LinuxBridgePlugin.LinuxBridgePlugin
+;;
+
+"nicira")
+	quantum-config-set ${Q_CONF} PLUGIN provider quantum.plugins.nicira.nicira_nvp_plugin.QuantumPlugin.NvpPlugin
+        echo "No database support"
+        exit 0;
+;;
+
+"openvswitch")
+	if ! rpm -q openvswitch > /dev/null 
+	then
+		echo "Please install openvswitch"
+		exit 0
+	fi
+	DB_NAME="ovs_quantum"
+	quantum-config-set ${Q_CONF} PLUGIN provider quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPlugin
+;;
+
+"ryu")
+	quantum-config-set ${Q_CONF} PLUGIN provider quantum.plugins.ryu.ryu_quantum_plugin.RyuQuantumPlugin
+	echo "No database support required"
+        exit 0;
+;;
+
+esac
+echo "Plugin: ${QUANTUM_PLUGIN} => Database: ${DB_NAME}"
+
+# Make sure MySQL is installed.
+
+NEW_MYSQL_INSTALL=0
+if ! rpm -q mysql-server > /dev/null
+then
+	if [ -z "${ASSUME_YES}" ] ; then
+		printf "mysql-server is not installed.  Would you like to install it now? (y/n): "
+		read response
+		case "$response" in
+			y|Y)
+				;;
+			n|N)
+				echo "mysql-server must be installed.  Please install it before proceeding."
+				exit 0
+				;;
+			*)
+				echo "Invalid response."
+				exit 1
+		esac
+	fi
+
+	NEW_MYSQL_INSTALL=1
+	install_mysql_server
+fi
+
+
+# Make sure mysqld is running.
+
+if ! systemctl status mysqld.service > /dev/null
+then
+	if [ -z "${ASSUME_YES}" ] ; then
+		printf "mysqld is not running.  Would you like to start it now? (y/n): "
+		read response
+		case "$response" in
+			y|Y)
+				;;
+			n|N)
+				echo "mysqld must be running.  Please start it before proceeding."
+				exit 0
+				;;
+			*)
+				echo "Invalid response."
+				exit 1
+		esac
+	fi
+
+	start_mysql_server
+
+	# If we both installed and started, ensure it starts at boot
+	[ $NEW_MYSQL_INSTALL -eq 1 ] && chkconfig mysqld on
+fi
+
+# Get MySQL root access.
+if [ $NEW_MYSQL_INSTALL -eq 1 ]
+then
+	if [ ! "${MYSQL_ROOT_PW+defined}" ] ; then
+		echo "Since this is a fresh installation of MySQL, please set a password for the 'root' mysql user."
+
+		PW_MATCH=0
+		while [ $PW_MATCH -eq 0 ]
+		do
+			printf "Enter new password for 'root' mysql user: "
+			read -s MYSQL_ROOT_PW
+			echo
+			printf "Enter new password again: "
+			read -s PW2
+			echo
+			if [ "${MYSQL_ROOT_PW}" = "${PW2}" ] ; then
+				PW_MATCH=1
+			else
+				echo "Passwords did not match."
+			fi
+		done
+	fi
+
+	echo "UPDATE mysql.user SET password = password('${MYSQL_ROOT_PW}') WHERE user = 'root'; DELETE FROM mysql.user WHERE user = ''; flush privileges;" | mysql -u root
+	if ! [ $? -eq 0 ] ; then
+		echo "Failed to set password for 'root' MySQL user."
+		exit 1
+	fi
+elif [ ! "${MYSQL_ROOT_PW+defined}" ] ; then
+	printf "Please enter the password for the 'root' MySQL user: "
+	read -s MYSQL_ROOT_PW
+	echo
+fi
+
+# Sanity check MySQL credentials.
+
+MYSQL_ROOT_PW_ARG=""
+if [ "${MYSQL_ROOT_PW+defined}" ]
+then
+	MYSQL_ROOT_PW_ARG="--password=${MYSQL_ROOT_PW}"
+fi
+echo "SELECT 1;" | mysql -u root ${MYSQL_ROOT_PW_ARG} > /dev/null
+if ! [ $? -eq 0 ]
+then
+	echo "Failed to connect to the MySQL server.  Please check your root user credentials."
+	exit 1
+fi
+echo "Verified connectivity to MySQL."
+
+# Create a database user - check if it does not exist prior
+USER_EXISTS=$(mysql -u root ${MYSQL_ROOT_PW_ARG} -e "SELECT user FROM mysql.user WHERE user='${QUANTUM_USER}'"|grep ${QUANTUM_USER} | wc -l)
+if [ ${USER_EXISTS} -ne 0 ]; then
+	echo "User ${QUANTUM_USER} already exists"
+else
+	mysql -u root ${MYSQL_ROOT_PW_ARG} -e "create user '${QUANTUM_USER}'@'%' identified by '${MYSQL_Q_PW}'"
+	mysql -u root ${MYSQL_ROOT_PW_ARG} -e "create user '${QUANTUM_USER}'@'localhost' identified by '${MYSQL_Q_PW}'"
+fi
+
+#create database
+DB_EXISTS=$(mysql -u root ${MYSQL_ROOT_PW_ARG} -e "show databases"|grep ${DB_NAME}| wc -l)
+if [ ${DB_EXISTS} -ne 0 ]; then
+	mysql -u root ${MYSQL_ROOT_PW_ARG} -e "drop database ${DB_NAME}"
+fi
+mysql -u root ${MYSQL_ROOT_PW_ARG} -e "create database ${DB_NAME}"
+
+# Configure database specifics
+case "${QUANTUM_PLUGIN}" in
+"cisco")
+        quantum-config-set ${CISCO_CONF} DATABASE user ${QUANTUM_USER}
+        quantum-config-set ${CISCO_CONF} DATABASE pass ${MYSQL_Q_PW}
+        quantum-config-set ${CISCO_CONF} DATABASE host `hostname`
+ 	SCHEDULER_DRIVER=quantum.plugins.cisco.nova.quantum_port_aware_scheduler.QuantumPortAwareScheduler
+	LIBVIRT_VIF_DRIVER=quantum.plugins.cisco.nova.vifdirect.Libvirt802dot1QbhDriver
+	LIBVIRT_VIF_TYPE=802.1Qbh
+;;
+
+"linuxbridge")
+	mysql -u root ${MYSQL_ROOT_PW_ARG} -e "grant all on quantum_linux_bridge.* to '${QUANTUM_USER}'@'%'"
+	mysql -u root ${MYSQL_ROOT_PW_ARG} -e "grant all on quantum_linux_bridge.* to '${QUANTUM_USER}'@'localhost'"
+	quantum-config-set ${LB_CONF} DATABASE connection mysql
+        quantum-config-set ${LB_CONF} DATABASE user ${QUANTUM_USER}
+        quantum-config-set ${LB_CONF} DATABASE pass ${MYSQL_Q_PW}
+	quantum-config-set ${LB_CONF} DATABASE host `hostname`
+	
+	echo "Please enter network device for VLAN trunking:"
+	read NETWORK_DEVICE
+	quantum-config-set ${LB_CONF} LINUX_BRIDGE physical_interface ${NETWORK_DEVICE}
+
+	LIBVIRT_VIF_TYPE=ethernet
+	LIBVIRT_VIF_DRIVER=nova.virt.libvirt.vif.QuantumLinuxBridgeVIFDriver
+	LINUX_INTERFACE_DRIVER=nova.network.linux_net.QuantumLinuxBridgeInterfaceDriver
+;;
+
+"openvswitch")
+	mysql -u root ${MYSQL_ROOT_PW_ARG} -e "grant all on ovs_quantum.* to '${QUANTUM_USER}'@'%'"
+	mysql -u root ${MYSQL_ROOT_PW_ARG} -e "grant all on ovs_quantum.* to '${QUANTUM_USER}'@'localhost'"
+        quantum-config-set ${OVS_CONF} DATABASE sql_connection mysql://${QUANTUM_USER}:${MYSQL_Q_PW}@`hostname`/ovs_quantum
+	LIBVIRT_VIF_TYPE=ethernet
+	LIBVIRT_VIF_DRIVER=nova.virt.libvirt.vif.LibvirtOpenVswitchDriver
+	LINUX_INTERFACE_DRIVER=nova.network.linux_net.LinuxOVSInterfaceDriver
+;;
+esac
+
+echo "Would you like to update the nova configuration files? (y/n): "
+read response
+case "$response" in
+y|Y)
+	;;
+*)
+	echo "Complete!"
+	exit 0
+esac
+
+# If OpenStack is installed then configure nova.conf
+if ! [ -e "${NOVA_CONF}" ]; then
+        echo "Please install OpenStack compute and then set the values"
+	echo "in /etc/nova/nova.conf DEFAULT section"
+	echo "    network_manager=nova.network.quantum.manager.QuantumManager"
+        echo "    quantum_connection_host=`hostname`"
+        echo "    quantum_connection_port=9696"
+        echo "    quantum_use_dhcp=True"
+        echo "    scheduler_driver=${SCHEDULER_DRIVER}"
+        echo "    libvirt_vif_driver=${LIBVIRT_VIF_DRIVER}"
+        echo "    libvirt_vif_type=${LIBVIRT_VIF_TYPE}"
+        echo "    linuxnet_interface_driver=${LINUX_INTERFACE_DRIVER}"
+else
+	openstack-config-set ${NOVA_CONF} DEFAULT network_manager nova.network.quantum.manager.QuantumManager
+        openstack-config-set ${NOVA_CONF} DEFAULT quantum_connection_host `hostname`
+        openstack-config-set ${NOVA_CONF} DEFAULT quantum_connection_port 9696
+        openstack-config-set ${NOVA_CONF} DEFAULT quantum_use_dhcp True
+        if [ ${SCHEDULER_DRIVER} ]; then
+                openstack-config-set ${NOVA_CONF} DEFAULT scheduler_driver ${SCHEDULER_DRIVER}
+        fi
+        if [ ${LIBVIRT_VIF_DRIVER} ]; then
+                openstack-config-set ${NOVA_CONF} DEFAULT libvirt_vif_driver ${LIBVIRT_VIF_DRIVER}
+        fi
+        if [ ${LIBVIRT_VIF_TYPE} ]; then
+                openstack-config-set ${NOVA_CONF} DEFAULT libvirt_vif_type ${LIBVIRT_VIF_TYPE}
+        fi
+        if [ ${LINUX_INTERFACE_DRIVER} ]; then
+                openstack-config-set ${NOVA_CONF} DEFAULT linuxnet_interface_driver ${LINUX_INTERFACE_DRIVER}
+        fi
+fi
+
+echo "Configuration updates complete!"
diff --git a/sources b/sources
index 95270e3..f9a4792 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-b4969a651b9a039cb4daded630f80610  quantum-2012.1~rc1~20120316.764.tar.gz
+1b0dd0f0599597ab39232b50eb11260b  quantum-2012.1~rc1.tar.gz


More information about the scm-commits mailing list