setup-networkmanager.sh 6.83 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 45 46 47 48
#
# This is a nasty bug in oslo_service; see 
# https://review.openstack.org/#/c/256267/
#
if [ $OSVERSION -ge $OSKILO ]; then
    maybe_install_packages python-oslo.service
    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
# Configure the L3 agent.
crudini --set /etc/neutron/l3_agent.ini DEFAULT \
62
    interface_driver $interface_driver
63
crudini --set /etc/neutron/l3_agent.ini DEFAULT use_namespaces True
64 65 66 67 68
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
69 70 71 72 73 74
#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 \
75
    interface_driver $interface_driver
76 77
crudini --set /etc/neutron/dhcp_agent.ini DEFAULT \
    dhcp_driver neutron.agent.linux.dhcp.Dnsmasq
78 79 80 81 82 83
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
else
    crudini --set /etc/neutron/dhcp_agent.ini DEFAULT enable_isolated_metadata True
fi
84 85
crudini --set /etc/neutron/dhcp_agent.ini DEFAULT verbose ${VERBOSE_LOGGING}
crudini --set /etc/neutron/dhcp_agent.ini DEFAULT debug ${DEBUG_LOGGING}
86

87 88 89 90 91 92 93
#
# 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.
#

94
# Uncomment if dhcp has trouble due to MTU
95 96 97
crudini --set /etc/neutron/dhcp_agent.ini DEFAULT \
    dnsmasq_config_file /etc/neutron/dnsmasq-neutron.conf
cat <<EOF >>/etc/neutron/dnsmasq-neutron.conf
98
dhcp-option-force=26,1450
99 100 101 102
log-queries
log-dhcp
no-resolv
server=8.8.8.8
103 104
EOF
pkill dnsmasq
105

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

169
if [ $USE_NEUTRON_LBAAS -eq 1 -a $OSVERSION -ge $OSNEWTON ]; then
170
    crudini --set /etc/neutron/lbaas_agent.ini DEFAULT \
171 172 173 174 175 176 177 178 179 180 181 182 183
	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"
184
fi
185

186 187 188 189 190 191 192 193
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
194
if [ $USE_NEUTRON_LBAAS -eq 1 -a $OSVERSION -ge $OSNEWTON ]; then
195 196 197
    service_restart neutron-lbaasv2-agent
    service_enable neutron-lbaasv2-agent
fi
198 199 200

touch $OURDIR/setup-networkmanager-done

201 202
logtend "networkmanager"

203
exit 0