Add enable_tunneling openvswitch configuration variable
Not all systems that support Open vSwitch support its GRE tunneling feature that is not in the Linux kernel source tree. Therefore, a new configuration variable, enable_tunneling, applies to both the server and agent. Its default value is False, so it must be set to True to enable tunneling for tenant and/or provider networks. If enable_tunneling is False, the server will not allow creation of GRE networks, and the agent will not initialize the tunnel bridge and will log an error if there is an attempt to provision a GRE network. If it is True, the agent now logs an error and exits if it fails to initialize the patch ports used for the tunnel bridge. Fixes bug 1045610. When there is an attempt to provision a flat or VLAN network and the agent has no bridge mapping configured for a the specified physical network, the agent will now log an error rather than crash. An undefined variable in a logging statement has been corrected. Logging levels for openvswitch have been checked and updated where necessary, and logging statements now avoid the % string substitution syntax. Fixes bug 1045592. The corresponding devstack update has already been merged. Change-Id: I149db182dd132cc05802dcb20c6b552e293664a5
This commit is contained in:
parent
39b74e42ec
commit
00dd97c7e9
@ -34,6 +34,12 @@ reconnect_interval = 2
|
||||
# Default: network_vlan_ranges =
|
||||
# Example: network_vlan_ranges = physnet1:1000:2999
|
||||
|
||||
# (BoolOpt) Set to True in the server and the agents to enable support
|
||||
# for GRE networks. Requires kernel support for OVS patch ports and
|
||||
# GRE tunneling.
|
||||
#
|
||||
# Default: enable_tunneling = False
|
||||
|
||||
# (ListOpt) Comma-separated list of <tun_min>:<tun_max> tuples
|
||||
# enumerating ranges of GRE tunnel IDs that are available for tenant
|
||||
# network allocation if tenant_network_type is 'gre'.
|
||||
|
@ -135,7 +135,7 @@ class OVSQuantumAgent(object):
|
||||
|
||||
def __init__(self, integ_br, tun_br, local_ip,
|
||||
bridge_mappings, root_helper,
|
||||
polling_interval, reconnect_interval, rpc):
|
||||
polling_interval, reconnect_interval, rpc, enable_tunneling):
|
||||
'''Constructor.
|
||||
|
||||
:param integ_br: name of the integration bridge.
|
||||
@ -146,6 +146,7 @@ class OVSQuantumAgent(object):
|
||||
:param polling_interval: interval (secs) to poll DB.
|
||||
:param reconnect_internal: retry interval (secs) on DB error.
|
||||
:param rpc: if True use RPC interface to interface with plugin.
|
||||
:param enable_tunneling: if True enable GRE networks.
|
||||
'''
|
||||
self.root_helper = root_helper
|
||||
self.available_local_vlans = set(
|
||||
@ -158,9 +159,11 @@ class OVSQuantumAgent(object):
|
||||
self.polling_interval = polling_interval
|
||||
self.reconnect_interval = reconnect_interval
|
||||
|
||||
self.enable_tunneling = enable_tunneling
|
||||
self.local_ip = local_ip
|
||||
self.tunnel_count = 0
|
||||
self.setup_tunnel_br(tun_br)
|
||||
if self.enable_tunneling:
|
||||
self.setup_tunnel_br(tun_br)
|
||||
|
||||
self.rpc = rpc
|
||||
if rpc:
|
||||
@ -214,6 +217,8 @@ class OVSQuantumAgent(object):
|
||||
|
||||
def tunnel_update(self, context, **kwargs):
|
||||
LOG.debug("tunnel_update received")
|
||||
if not self.enable_tunneling:
|
||||
return
|
||||
tunnel_ip = kwargs.get('tunnel_ip')
|
||||
tunnel_id = kwargs.get('tunnel_id')
|
||||
if tunnel_ip == self.local_ip:
|
||||
@ -240,54 +245,72 @@ class OVSQuantumAgent(object):
|
||||
'''
|
||||
|
||||
if not self.available_local_vlans:
|
||||
raise Exception("No local VLAN available for net-id=%s" % net_uuid)
|
||||
LOG.error("No local VLAN available for net-id=%s", net_uuid)
|
||||
return
|
||||
lvid = self.available_local_vlans.pop()
|
||||
LOG.info("Assigning %s as local vlan for net-id=%s" % (lvid, net_uuid))
|
||||
LOG.info("Assigning %s as local vlan for net-id=%s", lvid, net_uuid)
|
||||
self.local_vlan_map[net_uuid] = LocalVLANMapping(lvid, network_type,
|
||||
physical_network,
|
||||
segmentation_id)
|
||||
|
||||
if network_type == constants.TYPE_GRE:
|
||||
# outbound
|
||||
self.tun_br.add_flow(priority=4, in_port=self.patch_int_ofport,
|
||||
dl_vlan=lvid,
|
||||
actions="set_tunnel:%s,normal" %
|
||||
segmentation_id)
|
||||
# inbound bcast/mcast
|
||||
self.tun_br.add_flow(priority=3, tun_id=segmentation_id,
|
||||
dl_dst="01:00:00:00:00:00/01:00:00:00:00:00",
|
||||
actions="mod_vlan_vid:%s,output:%s" %
|
||||
(lvid, self.patch_int_ofport))
|
||||
if self.enable_tunneling:
|
||||
# outbound
|
||||
self.tun_br.add_flow(priority=4, in_port=self.patch_int_ofport,
|
||||
dl_vlan=lvid,
|
||||
actions="set_tunnel:%s,normal" %
|
||||
segmentation_id)
|
||||
# inbound bcast/mcast
|
||||
self.tun_br.add_flow(priority=3, tun_id=segmentation_id,
|
||||
dl_dst=
|
||||
"01:00:00:00:00:00/01:00:00:00:00:00",
|
||||
actions="mod_vlan_vid:%s,output:%s" %
|
||||
(lvid, self.patch_int_ofport))
|
||||
else:
|
||||
LOG.error("Cannot provision GRE network for net-id=%s "
|
||||
"- tunneling disabled", net_uuid)
|
||||
elif network_type == constants.TYPE_FLAT:
|
||||
# outbound
|
||||
br = self.phys_brs[physical_network]
|
||||
br.add_flow(priority=4,
|
||||
in_port=self.phys_ofports[physical_network],
|
||||
dl_vlan=lvid,
|
||||
actions="strip_vlan,normal")
|
||||
# inbound
|
||||
self.int_br.add_flow(priority=3,
|
||||
in_port=self.int_ofports[physical_network],
|
||||
dl_vlan=0xffff,
|
||||
actions="mod_vlan_vid:%s,normal" % lvid)
|
||||
if physical_network in self.phys_brs:
|
||||
# outbound
|
||||
br = self.phys_brs[physical_network]
|
||||
br.add_flow(priority=4,
|
||||
in_port=self.phys_ofports[physical_network],
|
||||
dl_vlan=lvid,
|
||||
actions="strip_vlan,normal")
|
||||
# inbound
|
||||
self.int_br.add_flow(priority=3,
|
||||
in_port=
|
||||
self.int_ofports[physical_network],
|
||||
dl_vlan=0xffff,
|
||||
actions="mod_vlan_vid:%s,normal" % lvid)
|
||||
else:
|
||||
LOG.error("Cannot provision flat network for net-id=%s "
|
||||
"- no bridge for physical_network %s", net_uuid,
|
||||
physical_network)
|
||||
elif network_type == constants.TYPE_VLAN:
|
||||
# outbound
|
||||
br = self.phys_brs[physical_network]
|
||||
br.add_flow(priority=4,
|
||||
in_port=self.phys_ofports[physical_network],
|
||||
dl_vlan=lvid,
|
||||
actions="mod_vlan_vid:%s,normal" % segmentation_id)
|
||||
# inbound
|
||||
self.int_br.add_flow(priority=3,
|
||||
in_port=self.int_ofports[physical_network],
|
||||
dl_vlan=segmentation_id,
|
||||
actions="mod_vlan_vid:%s,normal" % lvid)
|
||||
if physical_network in self.phys_brs:
|
||||
# outbound
|
||||
br = self.phys_brs[physical_network]
|
||||
br.add_flow(priority=4,
|
||||
in_port=self.phys_ofports[physical_network],
|
||||
dl_vlan=lvid,
|
||||
actions="mod_vlan_vid:%s,normal" % segmentation_id)
|
||||
# inbound
|
||||
self.int_br.add_flow(priority=3,
|
||||
in_port=self.
|
||||
int_ofports[physical_network],
|
||||
dl_vlan=segmentation_id,
|
||||
actions="mod_vlan_vid:%s,normal" % lvid)
|
||||
else:
|
||||
LOG.error("Cannot provision VLAN network for net-id=%s "
|
||||
"- no bridge for physical_network %s", net_uuid,
|
||||
physical_network)
|
||||
elif network_type == constants.TYPE_LOCAL:
|
||||
# no flows needed for local networks
|
||||
pass
|
||||
else:
|
||||
LOG.error("provisioning unknown network type %s for net-id=%s" %
|
||||
(network_type, net_uuid))
|
||||
LOG.error("Cannot provision unknown network type %s for "
|
||||
"net-id=%s", network_type, net_uuid)
|
||||
|
||||
def reclaim_local_vlan(self, net_uuid, lvm):
|
||||
'''Reclaim a local VLAN.
|
||||
@ -295,36 +318,40 @@ class OVSQuantumAgent(object):
|
||||
:param net_uuid: the network uuid associated with this vlan.
|
||||
:param lvm: a LocalVLANMapping object that tracks (vlan, lsw_id,
|
||||
vif_ids) mapping.'''
|
||||
LOG.info("reclaiming vlan = %s from net-id = %s" %
|
||||
(lvm.vlan, net_uuid))
|
||||
LOG.info("Reclaiming vlan = %s from net-id = %s", lvm.vlan, net_uuid)
|
||||
|
||||
if lvm.network_type == constants.TYPE_GRE:
|
||||
self.tun_br.delete_flows(tun_id=lvm.segmentation_id)
|
||||
self.tun_br.delete_flows(dl_vlan=lvm.vlan)
|
||||
if self.enable_tunneling:
|
||||
self.tun_br.delete_flows(tun_id=lvm.segmentation_id)
|
||||
self.tun_br.delete_flows(dl_vlan=lvm.vlan)
|
||||
elif lvm.network_type == constants.TYPE_FLAT:
|
||||
# outbound
|
||||
br = self.phys_brs[lvm.physical_network]
|
||||
br.delete_flows(in_port=self.phys_ofports[lvm.physical_network],
|
||||
dl_vlan=lvm.vlan)
|
||||
# inbound
|
||||
br = self.int_br
|
||||
br.delete_flows(in_port=self.int_ofports[lvm.physical_network],
|
||||
dl_vlan=0xffff)
|
||||
if lvm.physical_network in self.phy_brs:
|
||||
# outbound
|
||||
br = self.phys_brs[lvm.physical_network]
|
||||
br.delete_flows(in_port=self.phys_ofports[lvm.
|
||||
physical_network],
|
||||
dl_vlan=lvm.vlan)
|
||||
# inbound
|
||||
br = self.int_br
|
||||
br.delete_flows(in_port=self.int_ofports[lvm.physical_network],
|
||||
dl_vlan=0xffff)
|
||||
elif lvm.network_type == constants.TYPE_VLAN:
|
||||
# outbound
|
||||
br = self.phys_brs[lvm.physical_network]
|
||||
br.delete_flows(in_port=self.phys_ofports[lvm.physical_network],
|
||||
dl_vlan=lvm.vlan)
|
||||
# inbound
|
||||
br = self.int_br
|
||||
br.delete_flows(in_port=self.int_ofports[lvm.physical_network],
|
||||
dl_vlan=lvm.segmentation_id)
|
||||
if lvm.physical_network in self.phy_brs:
|
||||
# outbound
|
||||
br = self.phys_brs[lvm.physical_network]
|
||||
br.delete_flows(in_port=self.phys_ofports[lvm.
|
||||
physical_network],
|
||||
dl_vlan=lvm.vlan)
|
||||
# inbound
|
||||
br = self.int_br
|
||||
br.delete_flows(in_port=self.int_ofports[lvm.physical_network],
|
||||
dl_vlan=lvm.segmentation_id)
|
||||
elif lvm.network_type == constants.TYPE_LOCAL:
|
||||
# no flows needed for local networks
|
||||
pass
|
||||
else:
|
||||
LOG.error("reclaiming unknown network type %s for net-id=%s" %
|
||||
(lvm.network_type, net_uuid))
|
||||
LOG.error("Cannot reclaim unknown network type %s for net-id=%s",
|
||||
lvm.network_type, net_uuid)
|
||||
|
||||
del self.local_vlan_map[net_uuid]
|
||||
self.available_local_vlans.add(lvm.vlan)
|
||||
@ -347,10 +374,12 @@ class OVSQuantumAgent(object):
|
||||
lvm.vif_ports[port.vif_id] = port
|
||||
|
||||
if network_type == constants.TYPE_GRE:
|
||||
# inbound unicast
|
||||
self.tun_br.add_flow(priority=3, tun_id=segmentation_id,
|
||||
dl_dst=port.vif_mac,
|
||||
actions="mod_vlan_vid:%s,normal" % lvm.vlan)
|
||||
if self.enable_tunneling:
|
||||
# inbound unicast
|
||||
self.tun_br.add_flow(priority=3, tun_id=segmentation_id,
|
||||
dl_dst=port.vif_mac,
|
||||
actions="mod_vlan_vid:%s,normal" %
|
||||
lvm.vlan)
|
||||
|
||||
self.int_br.set_db_attribute("Port", port.port_name, "tag",
|
||||
str(lvm.vlan))
|
||||
@ -369,20 +398,20 @@ class OVSQuantumAgent(object):
|
||||
net_uuid = self.get_net_uuid(vif_id)
|
||||
|
||||
if not self.local_vlan_map.get(net_uuid):
|
||||
LOG.info('port_unbound() net_uuid %s not in local_vlan_map' %
|
||||
LOG.info('port_unbound() net_uuid %s not in local_vlan_map',
|
||||
net_uuid)
|
||||
return
|
||||
lvm = self.local_vlan_map[net_uuid]
|
||||
if lvm.network_type == 'gre':
|
||||
# remove inbound unicast flow
|
||||
self.tun_br.delete_flows(tun_id=lvm.segmentation_id,
|
||||
dl_dst=lvm.vif_ports[vif_id].vif_mac)
|
||||
if self.enable_tunneling:
|
||||
# remove inbound unicast flow
|
||||
self.tun_br.delete_flows(tun_id=lvm.segmentation_id,
|
||||
dl_dst=lvm.vif_ports[vif_id].vif_mac)
|
||||
|
||||
if vif_id in lvm.vif_ports:
|
||||
del lvm.vif_ports[vif_id]
|
||||
else:
|
||||
LOG.info('port_unbound: vid_id %s not in local_vlan_map' %
|
||||
port.vif_id)
|
||||
LOG.info('port_unbound: vif_id %s not in local_vlan_map', vif_id)
|
||||
|
||||
if not lvm.vif_ports:
|
||||
self.reclaim_local_vlan(net_uuid, lvm)
|
||||
@ -403,8 +432,6 @@ class OVSQuantumAgent(object):
|
||||
:param integ_br: the name of the integration bridge.'''
|
||||
self.int_br = ovs_lib.OVSBridge(integ_br, self.root_helper)
|
||||
self.int_br.delete_port("patch-tun")
|
||||
self.patch_tun_ofport = self.int_br.add_patch_port("patch-tun",
|
||||
"patch-int")
|
||||
self.int_br.remove_all_flows()
|
||||
# switch all traffic using L2 learning
|
||||
self.int_br.add_flow(priority=1, actions="normal")
|
||||
@ -418,8 +445,15 @@ class OVSQuantumAgent(object):
|
||||
:param tun_br: the name of the tunnel bridge.'''
|
||||
self.tun_br = ovs_lib.OVSBridge(tun_br, self.root_helper)
|
||||
self.tun_br.reset_bridge()
|
||||
self.patch_tun_ofport = self.int_br.add_patch_port("patch-tun",
|
||||
"patch-int")
|
||||
self.patch_int_ofport = self.tun_br.add_patch_port("patch-int",
|
||||
"patch-tun")
|
||||
if int(self.patch_tun_ofport) < 0 or int(self.patch_int_ofport) < 0:
|
||||
LOG.error("Failed to create OVS patch port. Cannot have tunneling "
|
||||
"enabled on this agent, since this version of OVS does "
|
||||
"not support tunnels or patch ports.")
|
||||
exit(1)
|
||||
self.tun_br.remove_all_flows()
|
||||
self.tun_br.add_flow(priority=1, actions="drop")
|
||||
|
||||
@ -437,8 +471,8 @@ class OVSQuantumAgent(object):
|
||||
for physical_network, bridge in bridge_mappings.iteritems():
|
||||
# setup physical bridge
|
||||
if not ip_lib.device_exists(bridge, self.root_helper):
|
||||
LOG.error("Bridge %s for physical network %s does not exist" %
|
||||
(bridge, physical_network))
|
||||
LOG.error("Bridge %s for physical network %s does not exist",
|
||||
bridge, physical_network)
|
||||
sys.exit(1)
|
||||
br = ovs_lib.OVSBridge(bridge, self.root_helper)
|
||||
br.remove_all_flows()
|
||||
@ -477,7 +511,7 @@ class OVSQuantumAgent(object):
|
||||
|
||||
new_tunnel_ips = tunnel_ips - old_tunnel_ips
|
||||
if new_tunnel_ips:
|
||||
LOG.info("adding tunnels to: %s" % new_tunnel_ips)
|
||||
LOG.info("Adding tunnels to: %s", new_tunnel_ips)
|
||||
for ip in new_tunnel_ips:
|
||||
tun_name = "gre-" + str(self.tunnel_count)
|
||||
self.tun_br.add_tunnel_port(tun_name, ip)
|
||||
@ -502,8 +536,8 @@ class OVSQuantumAgent(object):
|
||||
old_tunnel_ips = set()
|
||||
|
||||
db = sqlsoup.SqlSoup(db_connection_url)
|
||||
LOG.info("Connecting to database \"%s\" on %s" %
|
||||
(db.engine.url.database, db.engine.url.host))
|
||||
LOG.info("Connecting to database \"%s\" on %s",
|
||||
db.engine.url.database, db.engine.url.host)
|
||||
|
||||
while True:
|
||||
try:
|
||||
@ -514,8 +548,10 @@ class OVSQuantumAgent(object):
|
||||
for bind in
|
||||
db.ovs_network_bindings.all())
|
||||
|
||||
tunnel_ips = set(x.ip_address for x in db.ovs_tunnel_ips.all())
|
||||
self.manage_tunnels(tunnel_ips, old_tunnel_ips, db)
|
||||
if self.enable_tunneling:
|
||||
tunnel_ips = set(x.ip_address for x in
|
||||
db.ovs_tunnel_ips.all())
|
||||
self.manage_tunnels(tunnel_ips, old_tunnel_ips, db)
|
||||
|
||||
# Get bindings from OVS bridge.
|
||||
vif_ports = self.int_br.get_vif_ports()
|
||||
@ -574,7 +610,7 @@ class OVSQuantumAgent(object):
|
||||
new_net_uuid = new_port.network_id
|
||||
if new_net_uuid not in net_bindings:
|
||||
LOG.warn("No network binding found for net-id"
|
||||
" '%s'" % new_net_uuid)
|
||||
" '%s'", new_net_uuid)
|
||||
continue
|
||||
|
||||
bind = net_bindings[new_net_uuid]
|
||||
@ -584,9 +620,9 @@ class OVSQuantumAgent(object):
|
||||
bind.segmentation_id)
|
||||
all_bindings[p.vif_id].status = (
|
||||
q_const.PORT_STATUS_ACTIVE)
|
||||
LOG.info("Port %s on net-id = %s bound to %s " % (
|
||||
LOG.info("Port %s on net-id = %s bound to %s ",
|
||||
str(p), new_net_uuid,
|
||||
str(self.local_vlan_map[new_net_uuid])))
|
||||
str(self.local_vlan_map[new_net_uuid]))
|
||||
|
||||
for vif_id in disappeared_vif_ports_ids:
|
||||
LOG.info("Port Disappeared: " + vif_id)
|
||||
@ -602,7 +638,8 @@ class OVSQuantumAgent(object):
|
||||
|
||||
# sleep and re-initialize state for next pass
|
||||
time.sleep(self.polling_interval)
|
||||
old_tunnel_ips = tunnel_ips
|
||||
if self.enable_tunneling:
|
||||
old_tunnel_ips = tunnel_ips
|
||||
old_vif_ports = new_vif_ports
|
||||
old_local_bindings = new_local_bindings
|
||||
|
||||
@ -714,7 +751,7 @@ class OVSQuantumAgent(object):
|
||||
sync = False
|
||||
|
||||
# Notify the plugin of tunnel IP
|
||||
if tunnel_sync:
|
||||
if self.enable_tunneling and tunnel_sync:
|
||||
LOG.info("Agent tunnel out of sync with plugin!")
|
||||
tunnel_sync = self.tunnel_sync()
|
||||
|
||||
@ -757,6 +794,7 @@ def main():
|
||||
rpc = cfg.CONF.AGENT.rpc
|
||||
tun_br = cfg.CONF.OVS.tunnel_bridge
|
||||
local_ip = cfg.CONF.OVS.local_ip
|
||||
enable_tunneling = cfg.CONF.OVS.enable_tunneling
|
||||
|
||||
bridge_mappings = {}
|
||||
for mapping in cfg.CONF.OVS.bridge_mappings:
|
||||
@ -765,16 +803,15 @@ def main():
|
||||
try:
|
||||
physical_network, bridge = mapping.split(':')
|
||||
bridge_mappings[physical_network] = bridge
|
||||
LOG.debug("physical network %s mapped to bridge %s" %
|
||||
(physical_network, bridge))
|
||||
LOG.info("Physical network %s mapped to bridge %s",
|
||||
physical_network, bridge)
|
||||
except ValueError as ex:
|
||||
LOG.error("Invalid bridge mapping: \'%s\' - %s" %
|
||||
(mapping, ex))
|
||||
LOG.error("Invalid bridge mapping: \'%s\' - %s", mapping, ex)
|
||||
sys.exit(1)
|
||||
|
||||
plugin = OVSQuantumAgent(integ_br, tun_br, local_ip, bridge_mappings,
|
||||
root_helper, polling_interval,
|
||||
reconnect_interval, rpc)
|
||||
reconnect_interval, rpc, enable_tunneling)
|
||||
|
||||
# Start everything.
|
||||
plugin.daemon_loop(db_connection_url)
|
||||
|
@ -29,6 +29,7 @@ database_opts = [
|
||||
|
||||
ovs_opts = [
|
||||
cfg.StrOpt('integration_bridge', default='br-int'),
|
||||
cfg.BoolOpt('enable_tunneling', default=False),
|
||||
cfg.StrOpt('tunnel_bridge', default='br-tun'),
|
||||
cfg.StrOpt('local_ip', default='10.0.0.3'),
|
||||
cfg.ListOpt('bridge_mappings',
|
||||
|
@ -195,16 +195,22 @@ class OVSQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
||||
ovs_db_v2.initialize()
|
||||
self._parse_network_vlan_ranges()
|
||||
ovs_db_v2.sync_vlan_allocations(self.network_vlan_ranges)
|
||||
self._parse_tunnel_id_ranges()
|
||||
ovs_db_v2.sync_tunnel_allocations(self.tunnel_id_ranges)
|
||||
self.tenant_network_type = cfg.CONF.OVS.tenant_network_type
|
||||
if self.tenant_network_type not in [constants.TYPE_LOCAL,
|
||||
constants.TYPE_VLAN,
|
||||
constants.TYPE_GRE,
|
||||
constants.TYPE_NONE]:
|
||||
LOG.error("Invalid tenant_network_type: %s" %
|
||||
LOG.error("Invalid tenant_network_type: %s",
|
||||
self.tenant_network_type)
|
||||
sys.exit(1)
|
||||
self.enable_tunneling = cfg.CONF.OVS.enable_tunneling
|
||||
self.tunnel_id_ranges = []
|
||||
if self.enable_tunneling:
|
||||
self._parse_tunnel_id_ranges()
|
||||
ovs_db_v2.sync_tunnel_allocations(self.tunnel_id_ranges)
|
||||
elif self.tenant_network_type == constants.TYPE_GRE:
|
||||
LOG.error("Tunneling disabled but tenant_network_type is 'gre'")
|
||||
sys.exit(1)
|
||||
self.agent_rpc = cfg.CONF.AGENT.rpc
|
||||
self.setup_rpc()
|
||||
|
||||
@ -233,12 +239,12 @@ class OVSQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
||||
int(vlan_min),
|
||||
int(vlan_max))
|
||||
except ValueError as ex:
|
||||
LOG.error("Invalid network VLAN range: \'%s\' - %s" %
|
||||
(entry, ex))
|
||||
LOG.error("Invalid network VLAN range: \'%s\' - %s",
|
||||
entry, ex)
|
||||
sys.exit(1)
|
||||
else:
|
||||
self._add_network(entry)
|
||||
LOG.debug("network VLAN ranges: %s" % self.network_vlan_ranges)
|
||||
LOG.info("Network VLAN ranges: %s", self.network_vlan_ranges)
|
||||
|
||||
def _add_network_vlan_range(self, physical_network, vlan_min, vlan_max):
|
||||
self._add_network(physical_network)
|
||||
@ -249,17 +255,15 @@ class OVSQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
||||
self.network_vlan_ranges[physical_network] = []
|
||||
|
||||
def _parse_tunnel_id_ranges(self):
|
||||
self.tunnel_id_ranges = []
|
||||
for entry in cfg.CONF.OVS.tunnel_id_ranges:
|
||||
entry = entry.strip()
|
||||
try:
|
||||
tun_min, tun_max = entry.split(':')
|
||||
self.tunnel_id_ranges.append((int(tun_min), int(tun_max)))
|
||||
except ValueError as ex:
|
||||
LOG.error("Invalid tunnel ID range: \'%s\' - %s" %
|
||||
(entry, ex))
|
||||
LOG.error("Invalid tunnel ID range: \'%s\' - %s", entry, ex)
|
||||
sys.exit(1)
|
||||
LOG.debug("tunnel ID ranges: %s" % self.tunnel_id_ranges)
|
||||
LOG.info("Tunnel ID ranges: %s", self.tunnel_id_ranges)
|
||||
|
||||
# TODO(rkukura) Use core mechanism for attribute authorization
|
||||
# when available.
|
||||
@ -326,6 +330,9 @@ class OVSQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
||||
"(1 through 4094)")
|
||||
raise q_exc.InvalidInput(error_message=msg)
|
||||
elif network_type == constants.TYPE_GRE:
|
||||
if not self.enable_tunneling:
|
||||
msg = _("GRE networks are not enabled")
|
||||
raise q_exc.InvalidInput(error_message=msg)
|
||||
if physical_network_set:
|
||||
msg = _("provider:physical_network specified for GRE "
|
||||
"network")
|
||||
@ -420,7 +427,7 @@ class OVSQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
|
||||
self._extend_network_dict_provider(context, net)
|
||||
self._extend_network_dict_l3(context, net)
|
||||
# note - exception will rollback entire transaction
|
||||
LOG.debug("Created network: %s" % net['id'])
|
||||
LOG.debug("Created network: %s", net['id'])
|
||||
return net
|
||||
|
||||
def update_network(self, context, id, network):
|
||||
|
@ -23,12 +23,14 @@ class ConfigurationTest(unittest.TestCase):
|
||||
|
||||
def test_defaults(self):
|
||||
self.assertEqual('br-int', cfg.CONF.OVS.integration_bridge)
|
||||
self.assertFalse(cfg.CONF.OVS.enable_tunneling)
|
||||
self.assertEqual('br-tun', cfg.CONF.OVS.tunnel_bridge)
|
||||
self.assertEqual('sqlite://', cfg.CONF.DATABASE.sql_connection)
|
||||
self.assertEqual(-1, cfg.CONF.DATABASE.sql_max_retries)
|
||||
self.assertEqual(2, cfg.CONF.DATABASE.reconnect_interval)
|
||||
self.assertEqual(2, cfg.CONF.AGENT.polling_interval)
|
||||
self.assertEqual('sudo', cfg.CONF.AGENT.root_helper)
|
||||
self.assertTrue(cfg.CONF.AGENT.rpc)
|
||||
self.assertEqual('local', cfg.CONF.OVS.tenant_network_type)
|
||||
self.assertEqual(0, len(cfg.CONF.OVS.bridge_mappings))
|
||||
self.assertEqual(0, len(cfg.CONF.OVS.network_vlan_ranges))
|
||||
|
@ -56,19 +56,19 @@ class TunnelTest(unittest.TestCase):
|
||||
|
||||
self.INT_BRIDGE = 'integration_bridge'
|
||||
self.TUN_BRIDGE = 'tunnel_bridge'
|
||||
self.INT_OFPORT = 'PATCH_INT_OFPORT'
|
||||
self.TUN_OFPORT = 'PATCH_TUN_OFPORT'
|
||||
self.INT_OFPORT = 11111
|
||||
self.TUN_OFPORT = 22222
|
||||
|
||||
self.mox.StubOutClassWithMocks(ovs_lib, 'OVSBridge')
|
||||
self.mock_int_bridge = ovs_lib.OVSBridge(self.INT_BRIDGE, 'sudo')
|
||||
self.mock_int_bridge.delete_port('patch-tun')
|
||||
self.mock_int_bridge.add_patch_port(
|
||||
'patch-tun', 'patch-int').AndReturn(self.TUN_OFPORT)
|
||||
self.mock_int_bridge.remove_all_flows()
|
||||
self.mock_int_bridge.add_flow(priority=1, actions='normal')
|
||||
|
||||
self.mock_tun_bridge = ovs_lib.OVSBridge(self.TUN_BRIDGE, 'sudo')
|
||||
self.mock_tun_bridge.reset_bridge()
|
||||
self.mock_int_bridge.add_patch_port(
|
||||
'patch-tun', 'patch-int').AndReturn(self.TUN_OFPORT)
|
||||
self.mock_tun_bridge.add_patch_port(
|
||||
'patch-int', 'patch-tun').AndReturn(self.INT_OFPORT)
|
||||
self.mock_tun_bridge.remove_all_flows()
|
||||
@ -83,7 +83,7 @@ class TunnelTest(unittest.TestCase):
|
||||
b = ovs_quantum_agent.OVSQuantumAgent(self.INT_BRIDGE,
|
||||
self.TUN_BRIDGE,
|
||||
'10.0.0.1', {},
|
||||
'sudo', 2, 2, False)
|
||||
'sudo', 2, 2, False, True)
|
||||
self.mox.VerifyAll()
|
||||
|
||||
def testProvisionLocalVlan(self):
|
||||
@ -100,7 +100,7 @@ class TunnelTest(unittest.TestCase):
|
||||
a = ovs_quantum_agent.OVSQuantumAgent(self.INT_BRIDGE,
|
||||
self.TUN_BRIDGE,
|
||||
'10.0.0.1', {},
|
||||
'sudo', 2, 2, False)
|
||||
'sudo', 2, 2, False, True)
|
||||
a.available_local_vlans = set([LV_ID])
|
||||
a.provision_local_vlan(NET_UUID, 'gre', None, LS_ID)
|
||||
self.mox.VerifyAll()
|
||||
@ -114,7 +114,7 @@ class TunnelTest(unittest.TestCase):
|
||||
a = ovs_quantum_agent.OVSQuantumAgent(self.INT_BRIDGE,
|
||||
self.TUN_BRIDGE,
|
||||
'10.0.0.1', {},
|
||||
'sudo', 2, 2, False)
|
||||
'sudo', 2, 2, False, True)
|
||||
a.available_local_vlans = set()
|
||||
a.local_vlan_map[NET_UUID] = LVM
|
||||
a.reclaim_local_vlan(NET_UUID, LVM)
|
||||
@ -135,7 +135,7 @@ class TunnelTest(unittest.TestCase):
|
||||
a = ovs_quantum_agent.OVSQuantumAgent(self.INT_BRIDGE,
|
||||
self.TUN_BRIDGE,
|
||||
'10.0.0.1', {},
|
||||
'sudo', 2, 2, False)
|
||||
'sudo', 2, 2, False, True)
|
||||
a.local_vlan_map[NET_UUID] = LVM
|
||||
a.port_bound(VIF_PORT, NET_UUID, 'gre', None, LS_ID)
|
||||
self.mox.VerifyAll()
|
||||
@ -146,7 +146,7 @@ class TunnelTest(unittest.TestCase):
|
||||
a = ovs_quantum_agent.OVSQuantumAgent(self.INT_BRIDGE,
|
||||
self.TUN_BRIDGE,
|
||||
'10.0.0.1', {},
|
||||
'sudo', 2, 2, False)
|
||||
'sudo', 2, 2, False, True)
|
||||
a.available_local_vlans = set([LV_ID])
|
||||
a.local_vlan_map[NET_UUID] = LVM
|
||||
a.port_unbound(VIF_ID, NET_UUID)
|
||||
@ -163,7 +163,7 @@ class TunnelTest(unittest.TestCase):
|
||||
a = ovs_quantum_agent.OVSQuantumAgent(self.INT_BRIDGE,
|
||||
self.TUN_BRIDGE,
|
||||
'10.0.0.1', {},
|
||||
'sudo', 2, 2, False)
|
||||
'sudo', 2, 2, False, True)
|
||||
a.available_local_vlans = set([LV_ID])
|
||||
a.local_vlan_map[NET_UUID] = LVM
|
||||
a.port_dead(VIF_PORT)
|
||||
|
Loading…
x
Reference in New Issue
Block a user