-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-networkmanager.sh
executable file
·215 lines (188 loc) · 7.19 KB
/
setup-networkmanager.sh
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#!/bin/sh
##
## Setup the OpenStack networkmanager node for Neutron.
##
set -x
# Gotta know the rules!
if [ $EUID -ne 0 ] ; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Grab our libs
. "`dirname $0`/setup-lib.sh"
if [ "$HOSTNAME" != "$NETWORKMANAGER" ]; then
exit 0;
fi
if [ -f $OURDIR/setup-networkmanager-done ]; then
exit 0
fi
logtstart "networkmanager"
if [ -f $SETTINGS ]; then
. $SETTINGS
fi
#
# Configure our Neutron ML2 plugin.
#
$DIRNAME/setup-network-plugin.sh
# Grab the neutron configuration we computed in setup-lib.sh
. $OURDIR/neutron.vars
#
# This is a nasty bug in oslo_service; see
# https://review.openstack.org/#/c/256267/
#
if [ $OSVERSION -ge $OSKILO -a $OSVERSION -lt $OSNEWTON ]; then
maybe_install_packages ${PYPKGPREFIX}-oslo.service
patch -d / -p0 < $DIRNAME/etc/oslo_service-liberty-sig-MAINLOOP.patch
fi
cat <<EOF >> /etc/sysctl.conf
net.ipv4.ip_forward=1
EOF
sysctl -p
maybe_install_packages neutron-l3-agent neutron-dhcp-agent neutron-metering-agent
if [ $USE_NEUTRON_LBAAS -eq 1 ]; then
maybe_install_packages neutron-lbaasv2-agent
fi
if [ $OSVERSION -eq $OSROCKY ]; then
crudini --set /etc/neutron/neutron.conf oslo_concurrency \
lock_path /var/lib/neutron/lock
crudini --set /etc/neutron/neutron.conf DEFAULT \
lock_path /var/lib/neutron/lock
mkdir -p /var/lib/neutron/lock/
chown neutron:neutron /var/lib/neutron/lock
fi
# Configure the L3 agent.
crudini --set /etc/neutron/l3_agent.ini DEFAULT \
interface_driver $interface_driver
crudini --set /etc/neutron/l3_agent.ini DEFAULT use_namespaces True
if [ "${ML2PLUGIN}" = "openvswitch" ]; then
crudini --set /etc/neutron/l3_agent.ini DEFAULT external_network_bridge br-ex
else
crudini --set /etc/neutron/l3_agent.ini DEFAULT external_network_bridge ''
fi
#crudini --set /etc/neutron/l3_agent.ini DEFAULT router_delete_namespaces True
crudini --set /etc/neutron/l3_agent.ini DEFAULT verbose ${VERBOSE_LOGGING}
crudini --set /etc/neutron/l3_agent.ini DEFAULT debug ${DEBUG_LOGGING}
# Configure the DHCP agent.
crudini --set /etc/neutron/dhcp_agent.ini DEFAULT \
interface_driver $interface_driver
crudini --set /etc/neutron/dhcp_agent.ini DEFAULT \
dhcp_driver neutron.agent.linux.dhcp.Dnsmasq
if [ "${ML2PLUGIN}" = "openvswitch" ]; then
crudini --set /etc/neutron/dhcp_agent.ini DEFAULT use_namespaces True
#crudini --set /etc/neutron/dhcp_agent.ini DEFAULT dhcp_delete_namespaces True
fi
# Enable this by default for >= Ocata; that's all I have tested.
if [ $OSVERSION -ge $OCATA ]; then
crudini --set /etc/neutron/dhcp_agent.ini DEFAULT \
enable_isolated_metadata True
fi
crudini --set /etc/neutron/dhcp_agent.ini DEFAULT verbose ${VERBOSE_LOGGING}
crudini --set /etc/neutron/dhcp_agent.ini DEFAULT debug ${DEBUG_LOGGING}
#
# NB: theoretically, Mitaka and onwards automatically handles MTU, but
# suppose I mix GRE and VXLAN networks locally... I will fragment. So
# let's just be consistent and use 1450. This was previously broken for
# VXLANs on large packets because we were using the GRE-style MTU of 1454.
#
# Uncomment if dhcp has trouble due to MTU
crudini --set /etc/neutron/dhcp_agent.ini DEFAULT \
dnsmasq_config_file /etc/neutron/dnsmasq-neutron.conf
cat <<EOF >>/etc/neutron/dnsmasq-neutron.conf
dhcp-option-force=26,1450
log-queries
log-dhcp
no-resolv
server=8.8.8.8
EOF
pkill dnsmasq
# Setup the Metadata agent.
if [ $OSVERSION -lt $OSKILO ]; then
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
auth_url http://$CONTROLLER:5000/v2.0
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
auth_region $REGION
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
admin_tenant_name service
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
admin_user neutron
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
admin_password ${NEUTRON_PASS}
else
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
${AUTH_URI_KEY} http://${CONTROLLER}:5000
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
auth_url http://${CONTROLLER}:${KADMINPORT}/v2.0
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
auth_region $REGION
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
${AUTH_TYPE_PARAM} password
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
${PROJECT_DOMAIN_PARAM} default
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
${USER_DOMAIN_PARAM} default
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
project_name service
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
username neutron
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
password "${NEUTRON_PASS}"
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
admin_tenant_name service
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
admin_user neutron
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
admin_password "${NEUTRON_PASS}"
fi
if [ $OSVERSION -lt $OSPIKE ]; then
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
nova_metadata_ip ${CONTROLLER}
else
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
nova_metadata_host ${CONTROLLER}
fi
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
metadata_proxy_shared_secret ${NEUTRON_METADATA_SECRET}
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
verbose ${VERBOSE_LOGGING}
crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
debug ${DEBUG_LOGGING}
# Setup the metering agent.
crudini --set /etc/neutron/metering_agent.ini DEFAULT debug True
crudini --set /etc/neutron/metering_agent.ini DEFAULT \
driver neutron.services.metering.drivers.iptables.iptables_driver.IptablesMeteringDriver
crudini --set /etc/neutron/metering_agent.ini DEFAULT measure_interval 30
crudini --set /etc/neutron/metering_agent.ini DEFAULT report_interval 300
crudini --set /etc/neutron/metering_agent.ini DEFAULT \
interface_driver $interface_driver
crudini --set /etc/neutron/metering_agent.ini DEFAULT \
use_namespaces True
if [ $USE_NEUTRON_LBAAS -eq 1 ]; then
crudini --set /etc/neutron/lbaas_agent.ini DEFAULT \
device_driver "neutron_lbaas.drivers.haproxy.namespace_driver.HaproxyNSDriver"
if [ "${ML2PLUGIN}" = "linuxbridge" ]; then
crudini --set /etc/neutron/lbaas_agent.ini DEFAULT \
interface_driver "neutron.agent.linux.interface.BridgeInterfaceDriver"
else
crudini --set /etc/neutron/lbaas_agent.ini DEFAULT \
interface_driver "neutron.agent.linux.interface.OVSInterfaceDriver"
fi
crudini --set /etc/neutron/lbaas_agent.ini haproxy \
user_group "haproxy"
crudini --set /etc/neutron/neutron_lbaas.conf service_providers \
service_provider "LOADBALANCERV2:Haproxy:neutron_lbaas.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default"
fi
service_restart neutron-l3-agent
service_enable neutron-l3-agent
service_restart neutron-dhcp-agent
service_enable neutron-dhcp-agent
service_restart neutron-metadata-agent
service_enable neutron-metadata-agent
service_restart neutron-metering-agent
service_enable neutron-metering-agent
if [ $USE_NEUTRON_LBAAS -eq 1 ]; then
service_restart neutron-lbaasv2-agent
service_enable neutron-lbaasv2-agent
fi
touch $OURDIR/setup-networkmanager-done
logtend "networkmanager"
exit 0