Rebase on next
This commit is contained in:
commit
4e574ec76f
@ -21,6 +21,11 @@ options:
|
|||||||
default: False
|
default: False
|
||||||
type: boolean
|
type: boolean
|
||||||
description: Enable verbose logging
|
description: Enable verbose logging
|
||||||
|
data-port:
|
||||||
|
type: string
|
||||||
|
description: |
|
||||||
|
The data port will be added to br-data and will allow usage of flat or VLAN
|
||||||
|
network types
|
||||||
# Network configuration options
|
# Network configuration options
|
||||||
# by default all access is over 'private-address'
|
# by default all access is over 'private-address'
|
||||||
os-data-network:
|
os-data-network:
|
||||||
@ -31,4 +36,3 @@ options:
|
|||||||
.
|
.
|
||||||
This network will be used for tenant network traffic in overlay
|
This network will be used for tenant network traffic in overlay
|
||||||
networks.
|
networks.
|
||||||
|
|
||||||
|
@ -5,14 +5,17 @@ from charmhelpers.core.hookenv import (
|
|||||||
config,
|
config,
|
||||||
unit_get,
|
unit_get,
|
||||||
)
|
)
|
||||||
|
from charmhelpers.core.host import list_nics, get_nic_hwaddr
|
||||||
from charmhelpers.contrib.openstack import context
|
from charmhelpers.contrib.openstack import context
|
||||||
from charmhelpers.core.host import service_running, service_start
|
from charmhelpers.core.host import service_running, service_start
|
||||||
from charmhelpers.contrib.network.ovs import add_bridge
|
from charmhelpers.contrib.network.ovs import add_bridge, add_bridge_port
|
||||||
from charmhelpers.contrib.openstack.utils import get_host_ip
|
from charmhelpers.contrib.openstack.utils import get_host_ip
|
||||||
from charmhelpers.contrib.network.ip import get_address_in_network
|
from charmhelpers.contrib.network.ip import get_address_in_network
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
OVS_BRIDGE = 'br-int'
|
OVS_BRIDGE = 'br-int'
|
||||||
|
DATA_BRIDGE = 'br-data'
|
||||||
|
|
||||||
|
|
||||||
def _neutron_security_groups():
|
def _neutron_security_groups():
|
||||||
@ -45,10 +48,31 @@ class OVSPluginContext(context.NeutronContext):
|
|||||||
def neutron_security_groups(self):
|
def neutron_security_groups(self):
|
||||||
return _neutron_security_groups()
|
return _neutron_security_groups()
|
||||||
|
|
||||||
|
def get_data_port(self):
|
||||||
|
data_ports = config('data-port')
|
||||||
|
if not data_ports:
|
||||||
|
return None
|
||||||
|
hwaddrs = {}
|
||||||
|
for nic in list_nics(['eth', 'bond']):
|
||||||
|
hwaddrs[get_nic_hwaddr(nic).lower()] = nic
|
||||||
|
mac_regex = re.compile(r'([0-9A-F]{2}[:-]){5}([0-9A-F]{2})', re.I)
|
||||||
|
for entry in data_ports.split():
|
||||||
|
entry = entry.strip().lower()
|
||||||
|
if re.match(mac_regex, entry):
|
||||||
|
if entry in hwaddrs:
|
||||||
|
return hwaddrs[entry]
|
||||||
|
else:
|
||||||
|
return entry
|
||||||
|
return None
|
||||||
|
|
||||||
def _ensure_bridge(self):
|
def _ensure_bridge(self):
|
||||||
if not service_running('openvswitch-switch'):
|
if not service_running('openvswitch-switch'):
|
||||||
service_start('openvswitch-switch')
|
service_start('openvswitch-switch')
|
||||||
add_bridge(OVS_BRIDGE)
|
add_bridge(OVS_BRIDGE)
|
||||||
|
add_bridge(DATA_BRIDGE)
|
||||||
|
data_port = self.get_data_port()
|
||||||
|
if data_port:
|
||||||
|
add_bridge_port(DATA_BRIDGE, data_port, promisc=True)
|
||||||
|
|
||||||
def ovs_ctxt(self):
|
def ovs_ctxt(self):
|
||||||
# In addition to generating config context, ensure the OVS service
|
# In addition to generating config context, ensure the OVS service
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
# Config managed by neutron-openvswitch charm
|
# Config managed by neutron-openvswitch charm
|
||||||
###############################################################################
|
###############################################################################
|
||||||
[ml2]
|
[ml2]
|
||||||
type_drivers = gre,vxlan
|
type_drivers = gre,vxlan,vlan,flat
|
||||||
tenant_network_types = gre,vxlan
|
tenant_network_types = gre,vxlan,vlan,flat
|
||||||
mechanism_drivers = openvswitch
|
mechanism_drivers = openvswitch,hyperv
|
||||||
|
|
||||||
[ml2_type_gre]
|
[ml2_type_gre]
|
||||||
tunnel_id_ranges = 1:1000
|
tunnel_id_ranges = 1:1000
|
||||||
@ -15,9 +15,16 @@ tunnel_id_ranges = 1:1000
|
|||||||
[ml2_type_vxlan]
|
[ml2_type_vxlan]
|
||||||
vni_ranges = 1001:2000
|
vni_ranges = 1001:2000
|
||||||
|
|
||||||
|
[ml2_type_vlan]
|
||||||
|
network_vlan_ranges = physnet1:1000:2000
|
||||||
|
|
||||||
|
[ml2_type_flat]
|
||||||
|
flat_networks = physnet1
|
||||||
|
|
||||||
[ovs]
|
[ovs]
|
||||||
enable_tunneling = True
|
enable_tunneling = True
|
||||||
local_ip = {{ local_ip }}
|
local_ip = {{ local_ip }}
|
||||||
|
bridge_mappings = physnet1:br-data
|
||||||
|
|
||||||
[agent]
|
[agent]
|
||||||
tunnel_types = gre
|
tunnel_types = gre
|
||||||
|
@ -10,9 +10,12 @@ TO_PATCH = [
|
|||||||
'config',
|
'config',
|
||||||
'unit_get',
|
'unit_get',
|
||||||
'add_bridge',
|
'add_bridge',
|
||||||
|
'add_bridge_port',
|
||||||
'service_running',
|
'service_running',
|
||||||
'service_start',
|
'service_start',
|
||||||
'get_host_ip',
|
'get_host_ip',
|
||||||
|
'get_nic_hwaddr',
|
||||||
|
'list_nics',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -29,6 +32,38 @@ class OVSPluginContextTest(CharmTestCase):
|
|||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(OVSPluginContextTest, self).tearDown()
|
super(OVSPluginContextTest, self).tearDown()
|
||||||
|
|
||||||
|
def test_data_port_name(self):
|
||||||
|
self.test_config.set('data-port', 'em1')
|
||||||
|
self.assertEquals(context.OVSPluginContext().get_data_port(), 'em1')
|
||||||
|
|
||||||
|
def test_data_port_mac(self):
|
||||||
|
machine_machs = {
|
||||||
|
'em1': 'aa:aa:aa:aa:aa:aa',
|
||||||
|
'eth0': 'bb:bb:bb:bb:bb:bb',
|
||||||
|
}
|
||||||
|
absent_mac = "cc:cc:cc:cc:cc:cc"
|
||||||
|
config_macs = "%s %s" % (absent_mac, machine_machs['em1'])
|
||||||
|
self.test_config.set('data-port', config_macs)
|
||||||
|
|
||||||
|
def get_hwaddr(eth):
|
||||||
|
return machine_machs[eth]
|
||||||
|
self.get_nic_hwaddr.side_effect = get_hwaddr
|
||||||
|
self.list_nics.return_value = machine_machs.keys()
|
||||||
|
self.assertEquals(context.OVSPluginContext().get_data_port(), 'em1')
|
||||||
|
|
||||||
|
@patch.object(context.OVSPluginContext, 'get_data_port')
|
||||||
|
def test_ensure_bridge_data_port_present(self, get_data_port):
|
||||||
|
def add_port(bridge, port, promisc):
|
||||||
|
if bridge == 'br-data' and port == 'em1' and promisc is True:
|
||||||
|
self.bridge_added = True
|
||||||
|
return
|
||||||
|
self.bridge_added = False
|
||||||
|
|
||||||
|
get_data_port.return_value = 'em1'
|
||||||
|
self.add_bridge_port.side_effect = add_port
|
||||||
|
context.OVSPluginContext()._ensure_bridge()
|
||||||
|
self.assertEquals(self.bridge_added, True)
|
||||||
|
|
||||||
@patch.object(charmhelpers.contrib.openstack.context, 'config')
|
@patch.object(charmhelpers.contrib.openstack.context, 'config')
|
||||||
@patch.object(charmhelpers.contrib.openstack.context, 'unit_get')
|
@patch.object(charmhelpers.contrib.openstack.context, 'unit_get')
|
||||||
@patch.object(charmhelpers.contrib.openstack.context, 'is_clustered')
|
@patch.object(charmhelpers.contrib.openstack.context, 'is_clustered')
|
||||||
|
Loading…
Reference in New Issue
Block a user