Merge "Bug #949261 Removing nova drivers for Linux Bridge Plugin"
commit
9db5d73e31
|
@ -31,25 +31,25 @@ service with the Linux Bridge plugin.
|
|||
|
||||
# -- Nova configuration (controller node)
|
||||
|
||||
1) Make sure to set up nova using the quantum network manager in the
|
||||
1) Ensure that the quantum network manager is configured in the
|
||||
nova.conf on the node that will be running nova-network.
|
||||
|
||||
--network_manager=nova.network.quantum.manager.QuantumManager
|
||||
network_manager=nova.network.quantum.manager.QuantumManager
|
||||
|
||||
# -- Nova configuration (compute node(s))
|
||||
|
||||
1) Configure the vif driver, and libvirt/vif type
|
||||
|
||||
--connection_type=libvirt
|
||||
--libvirt_type=qemu
|
||||
--libvirt_vif_type=ethernet
|
||||
--libvirt_vif_driver=quantum.plugins.linuxbridge.nova.vif_linuxbridge_quantum.QuantumLibvirtLinuxBridgeVIFDriver
|
||||
--linuxnet_interface_driver=quantum.plugins.linuxbridge.nova.linux_net_linux_bridge.QuantumLinuxBridgeInterfaceDriver
|
||||
connection_type=libvirt
|
||||
libvirt_type=qemu
|
||||
libvirt_vif_type=ethernet
|
||||
libvirt_vif_driver=nova.virt.libvirt.vif.QuantumLinuxBridgeVIFDriver
|
||||
linuxnet_interface_driver=nova.network.linux_net.QuantumLinuxBridgeInterfaceDriver
|
||||
|
||||
2) If you want a DHCP server to be run for the VMs to acquire IPs,
|
||||
add the following flag to your nova.conf file:
|
||||
|
||||
--quantum_use_dhcp
|
||||
quantum_use_dhcp=true
|
||||
|
||||
(Note: For more details on how to work with Quantum using Nova, i.e. how to create networks and such,
|
||||
please refer to the top level Quantum README which points to the relevant documentation.)
|
||||
|
|
|
@ -1,117 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2012 Cisco Systems, Inc.
|
||||
# All Rights Reserved.
|
||||
# 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.
|
||||
#
|
||||
# Extends the linux_net.py kvm/linux network driver in Nova,
|
||||
# borrows structure and code
|
||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||
#
|
||||
|
||||
|
||||
"""Extends the linux_net driver when using the Linux Bridge plugin with
|
||||
QuantumManager"""
|
||||
|
||||
|
||||
from nova import exception
|
||||
from nova import log as logging
|
||||
from nova import utils
|
||||
|
||||
from nova.network.linux_net import *
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
BRDIGE_NAME_PREFIX = "brq"
|
||||
GATEWAY_INTERFACE_PREFIX = "gw-"
|
||||
|
||||
|
||||
def _device_exists(device):
|
||||
"""Check if ethernet device exists."""
|
||||
(_out, err) = utils.execute('ip', 'link', 'show', 'dev', device,
|
||||
check_exit_code=False)
|
||||
return not err
|
||||
|
||||
|
||||
# plugs interfaces using Linux Bridge when using QuantumManager
|
||||
class QuantumLinuxBridgeInterfaceDriver(LinuxNetInterfaceDriver):
|
||||
|
||||
def plug(self, network, mac_address, gateway=True):
|
||||
LOG.debug(_("inside plug()"))
|
||||
dev = self.get_dev(network)
|
||||
bridge = self.get_bridge(network)
|
||||
if not gateway:
|
||||
# If we weren't instructed to act as a gateway then add the
|
||||
# appropriate flows to block all non-dhcp traffic.
|
||||
# .. and make sure iptbles won't forward it as well.
|
||||
iptables_manager.ipv4['filter'].add_rule('FORWARD',
|
||||
'--in-interface %s -j DROP' % bridge)
|
||||
iptables_manager.ipv4['filter'].add_rule('FORWARD',
|
||||
'--out-interface %s -j DROP' % bridge)
|
||||
return bridge
|
||||
else:
|
||||
iptables_manager.ipv4['filter'].add_rule('FORWARD',
|
||||
'--in-interface %s -j ACCEPT' % bridge)
|
||||
iptables_manager.ipv4['filter'].add_rule('FORWARD',
|
||||
'--out-interface %s -j ACCEPT' % bridge)
|
||||
|
||||
if not _device_exists(dev):
|
||||
try:
|
||||
# First, try with 'ip'
|
||||
utils.execute('ip', 'tuntap', 'add', dev, 'mode', 'tap',
|
||||
run_as_root=True)
|
||||
except exception.ProcessExecutionError:
|
||||
# Second option: tunctl
|
||||
utils.execute('tunctl', '-b', '-t', dev, run_as_root=True)
|
||||
utils.execute('ip', 'link', 'set', dev, "address", mac_address,
|
||||
run_as_root=True)
|
||||
utils.execute('ip', 'link', 'set', dev, 'up', run_as_root=True)
|
||||
|
||||
if not _device_exists(bridge):
|
||||
LOG.debug(_("Starting bridge %s "), bridge)
|
||||
utils.execute('brctl', 'addbr', bridge, run_as_root=True)
|
||||
utils.execute('brctl', 'setfd', bridge, str(0), run_as_root=True)
|
||||
utils.execute('brctl', 'stp', bridge, 'off', run_as_root=True)
|
||||
utils.execute('ip', 'link', 'set', bridge, "address", mac_address,
|
||||
run_as_root=True)
|
||||
utils.execute('ip', 'link', 'set', bridge, 'up', run_as_root=True)
|
||||
LOG.debug(_("Done starting bridge %s"), bridge)
|
||||
|
||||
full_ip = '%s/%s' % (network['dhcp_server'],
|
||||
network['cidr'].rpartition('/')[2])
|
||||
utils.execute('ip', 'address', 'add', full_ip, 'dev', bridge,
|
||||
run_as_root=True)
|
||||
|
||||
return dev
|
||||
|
||||
def unplug(self, network):
|
||||
LOG.debug(_("inside unplug()"))
|
||||
dev = self.get_dev(network)
|
||||
try:
|
||||
utils.execute('ip', 'link', 'delete', dev, run_as_root=True)
|
||||
except exception.ProcessExecutionError:
|
||||
LOG.warning(_("Failed while unplugging gateway interface '%s'"),
|
||||
dev)
|
||||
raise
|
||||
LOG.debug(_("Unplugged gateway interface '%s'"), dev)
|
||||
return dev
|
||||
|
||||
def get_dev(self, network):
|
||||
dev = GATEWAY_INTERFACE_PREFIX + str(network['uuid'][0:11])
|
||||
return dev
|
||||
|
||||
def get_bridge(self, network):
|
||||
bridge = BRDIGE_NAME_PREFIX + str(network['uuid'][0:11])
|
||||
return bridge
|
|
@ -1,73 +0,0 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright (C) 2012 Midokura KK
|
||||
# Copyright (C) 2012 Nicira, Inc
|
||||
# Copyright (C) 2012 Cisco Systems, Inc
|
||||
# Copyright 2012 OpenStack LLC.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""
|
||||
VIF driver for libvirt when QuantumManager is configured with Linux Bridge
|
||||
plugin
|
||||
"""
|
||||
|
||||
from nova import flags
|
||||
from nova import log as logging
|
||||
from nova.network import linux_net
|
||||
from nova.virt import netutils
|
||||
from nova import utils
|
||||
from nova.virt.vif import VIFDriver
|
||||
from nova import exception
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
|
||||
class QuantumLibvirtLinuxBridgeVIFDriver(VIFDriver):
|
||||
"""VIF driver for Linux Bridge."""
|
||||
|
||||
def get_dev_name(_self, iface_id):
|
||||
return "tap" + iface_id[0:11]
|
||||
|
||||
def plug(self, instance, network, mapping):
|
||||
iface_id = mapping['vif_uuid']
|
||||
dev = self.get_dev_name(iface_id)
|
||||
if not linux_net._device_exists(dev):
|
||||
try:
|
||||
# First, try with 'ip'
|
||||
utils.execute('ip', 'tuntap', 'add', dev, 'mode', 'tap',
|
||||
run_as_root=True)
|
||||
except exception.ProcessExecutionError:
|
||||
# Second option: tunctl
|
||||
utils.execute('tunctl', '-b', '-t', dev, run_as_root=True)
|
||||
utils.execute('ip', 'link', 'set', dev, 'up', run_as_root=True)
|
||||
|
||||
result = {
|
||||
'script': '',
|
||||
'name': dev,
|
||||
'mac_address': mapping['mac']}
|
||||
return result
|
||||
|
||||
def unplug(self, instance, network, mapping):
|
||||
"""Unplug the VIF from the network by deleting the port from
|
||||
the bridge."""
|
||||
dev = self.get_dev_name(mapping['vif_uuid'])
|
||||
try:
|
||||
utils.execute('ip', 'link', 'delete', dev, run_as_root=True)
|
||||
except exception.ProcessExecutionError:
|
||||
LOG.warning(_("Failed while unplugging vif of instance '%s'"),
|
||||
instance['name'])
|
||||
raise
|
Loading…
Reference in New Issue