-
Notifications
You must be signed in to change notification settings - Fork 0
/
quantum-l3-setup
executable file
·138 lines (118 loc) · 3.55 KB
/
quantum-l3-setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/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=(linuxbridge openvswitch)
#
# Print --help output and exit.
#
usage() {
cat << EOF
The helper script will install the necessary support for the L3 agent.
Usage: quantum-l3-setup [options]
Options:
--help | -h
Print usage information.
--plugin | -p
The quantum plugin. Supported plugins:-
${SUPPORTED_PLUGINS[*]}
--qhost | -q
The Quantum hostname (assumes that this is also the QPID 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
}
L3_CONF=/etc/quantum/l3_agent.ini
L3_META_CONF=/etc/quantum/metadata_agent.ini
while [ $# -gt 0 ]
do
case "$1" in
-h|--help)
usage
;;
-p|--plugin)
shift
QUANTUM_PLUGIN=${1}
;;
-q|--qhost)
shift
Q_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 [ -z ${Q_HOST} ] ; then
echo "Please enter the Quantum hostname:"
read Q_HOST
fi
Q_PORT=9696
Q_CONF=/etc/quantum/quantum.conf
# QPID
openstack-config --set ${Q_CONF} DEFAULT rpc_backend quantum.openstack.common.rpc.impl_qpid
openstack-config --set ${Q_CONF} DEFAULT qpid_hostname ${Q_HOST}
case "${QUANTUM_PLUGIN}" in
"linuxbridge")
LINUX_INTERFACE_DRIVER=quantum.agent.linux.interface.BridgeInterfaceDriver
openstack-config --set ${L3_CONF} DEFAULT external_network_bridge ''
;;
"openvswitch")
if ! rpm -q openvswitch > /dev/null
then
echo "Please install openvswitch"
exit 0
fi
LINUX_INTERFACE_DRIVER=quantum.agent.linux.interface.OVSInterfaceDriver
;;
esac
# Keystone specific
OS_USERNAME=${OS_USERNAME:-quantum}
OS_PASSWORD=${OS_PASSWORD:-servicepass}
OS_AUTH_URL=${OS_AUTH_URL:-http://localhost:35357/v2.0/}
OS_TENANT_NAME=${OS_TENANT_NAME:-service}
# Update Keystone
openstack-config --set ${L3_META_CONF} DEFAULT auth_url ${OS_AUTH_URL}
openstack-config --set ${L3_META_CONF} DEFAULT admin_user ${OS_USERNAME}
openstack-config --set ${L3_META_CONF} DEFAULT admin_password ${OS_PASSWORD}
openstack-config --set ${L3_META_CONF} DEFAULT admin_tenant_name ${OS_TENANT_NAME}
# Update interface driver
openstack-config --set ${L3_CONF} DEFAULT interface_driver ${LINUX_INTERFACE_DRIVER}
echo "Configuration updates complete!"