All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

setup-networkmanager.sh 7.25 KB
Newer Older
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
#!/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

26 27
logtstart "networkmanager"

28 29 30 31
if [ -f $SETTINGS ]; then
    . $SETTINGS
fi

32 33 34 35 36 37 38 39
#
# Configure our Neutron ML2 plugin.
#
$DIRNAME/setup-network-plugin.sh

# Grab the neutron configuration we computed in setup-lib.sh
. $OURDIR/neutron.vars

40 41 42 43 44
#
# This is a nasty bug in oslo_service; see 
# https://review.openstack.org/#/c/256267/
#
if [ $OSVERSION -ge $OSKILO ]; then
45
    maybe_install_packages ${PYPKGPREFIX}-oslo.service
46 47 48
    patch -d / -p0 < $DIRNAME/etc/oslo_service-liberty-sig-MAINLOOP.patch
fi

49 50 51 52 53 54
cat <<EOF >> /etc/sysctl.conf
net.ipv4.ip_forward=1
EOF

sysctl -p

55
maybe_install_packages neutron-l3-agent neutron-dhcp-agent neutron-metering-agent
56
if [ $USE_NEUTRON_LBAAS -eq 1 -a $OSVERSION -ge $OSNEWTON ]; then
57 58
    maybe_install_packages neutron-lbaasv2-agent
fi
59

60 61 62
if [ $OSVERSION -eq $OSROCKY ]; then
    crudini --set /etc/neutron/neutron.conf oslo_concurrency \
	lock_path /var/lib/neutron/lock
63 64
    crudini --set /etc/neutron/neutron.conf DEFAULT \
	lock_path /var/lib/neutron/lock
65 66 67 68
    mkdir -p /var/lib/neutron/lock/
    chown neutron:neutron /var/lib/neutron/lock
fi

69 70
# Configure the L3 agent.
crudini --set /etc/neutron/l3_agent.ini DEFAULT \
71
    interface_driver $interface_driver
72
crudini --set /etc/neutron/l3_agent.ini DEFAULT use_namespaces True
73 74 75 76 77
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
78 79 80 81 82 83
#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 \
84
    interface_driver $interface_driver
85 86
crudini --set /etc/neutron/dhcp_agent.ini DEFAULT \
    dhcp_driver neutron.agent.linux.dhcp.Dnsmasq
87 88 89
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
90 91 92 93 94
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
95
fi
96 97
crudini --set /etc/neutron/dhcp_agent.ini DEFAULT verbose ${VERBOSE_LOGGING}
crudini --set /etc/neutron/dhcp_agent.ini DEFAULT debug ${DEBUG_LOGGING}
98

99 100 101 102 103 104 105
#
# 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.
#

106
# Uncomment if dhcp has trouble due to MTU
107 108 109
crudini --set /etc/neutron/dhcp_agent.ini DEFAULT \
    dnsmasq_config_file /etc/neutron/dnsmasq-neutron.conf
cat <<EOF >>/etc/neutron/dnsmasq-neutron.conf
110
dhcp-option-force=26,1450
111 112 113 114
log-queries
log-dhcp
no-resolv
server=8.8.8.8
115 116
EOF
pkill dnsmasq
117

118 119 120
# Setup the Metadata agent.
if [ $OSVERSION -lt $OSKILO ]; then
    crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
121
	auth_url http://$CONTROLLER:5000/v2.0
122 123 124 125 126 127 128 129 130 131
    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 \
132
	${AUTH_URI_KEY} http://${CONTROLLER}:5000
133
    crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
134
	auth_url http://${CONTROLLER}:${KADMINPORT}/v2.0
135 136 137
    crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
	auth_region $REGION
    crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
138
	${AUTH_TYPE_PARAM} password
139
    crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
140
	${PROJECT_DOMAIN_PARAM} default
141
    crudini --set /etc/neutron/metadata_agent.ini DEFAULT \
142
	${USER_DOMAIN_PARAM} default
143 144 145 146 147 148
    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}"
149 150 151 152 153 154
    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}"
155
fi
156 157 158 159 160 161 162
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
163 164 165 166 167 168 169 170 171 172 173 174 175 176
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 \
177
    interface_driver $interface_driver
178 179
crudini --set /etc/neutron/metering_agent.ini DEFAULT \
    use_namespaces True
180

181
if [ $USE_NEUTRON_LBAAS -eq 1 -a $OSVERSION -ge $OSNEWTON ]; then
182
    crudini --set /etc/neutron/lbaas_agent.ini DEFAULT \
183 184 185 186 187 188 189 190 191 192 193 194 195
	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"
196
fi
197

198 199 200 201 202 203 204 205
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
206
if [ $USE_NEUTRON_LBAAS -eq 1 -a $OSVERSION -ge $OSNEWTON ]; then
207 208 209
    service_restart neutron-lbaasv2-agent
    service_enable neutron-lbaasv2-agent
fi
210 211 212

touch $OURDIR/setup-networkmanager-done

213 214
logtend "networkmanager"

215
exit 0