Add dvr support
This commit is contained in:
parent
95f9d7d413
commit
3c7dd72d38
@ -1,3 +1,4 @@
|
||||
import ast
|
||||
from charmhelpers.core.hookenv import (
|
||||
relation_ids,
|
||||
related_units,
|
||||
@ -11,6 +12,7 @@ from charmhelpers.core.host import service_running, service_start
|
||||
from charmhelpers.contrib.network.ovs import add_bridge, add_bridge_port
|
||||
from charmhelpers.contrib.openstack.utils import get_host_ip
|
||||
from charmhelpers.contrib.network.ip import get_address_in_network
|
||||
from charmhelpers.contrib.openstack.context import OSContextGenerator
|
||||
|
||||
import re
|
||||
|
||||
@ -26,17 +28,19 @@ def _neutron_api_settings():
|
||||
'neutron_security_groups': False,
|
||||
'l2_population': True,
|
||||
'overlay_network_type': 'gre',
|
||||
'enable_dvr': False,
|
||||
}
|
||||
for rid in relation_ids('neutron-plugin-api'):
|
||||
for unit in related_units(rid):
|
||||
rdata = relation_get(rid=rid, unit=unit)
|
||||
if 'l2-population' not in rdata:
|
||||
continue
|
||||
neutron_settings = {
|
||||
'l2_population': rdata['l2-population'],
|
||||
'neutron_security_groups': rdata['neutron-security-groups'],
|
||||
'overlay_network_type': rdata['overlay-network-type'],
|
||||
}
|
||||
neutron_settings['l2_population'] = rdata['l2-population']
|
||||
if 'overlay-network-type' in rdata:
|
||||
neutron_settings['overlay_network_type'] = \
|
||||
rdata['overlay-network-type']
|
||||
if 'enable-dvr' in rdata:
|
||||
neutron_settings['enable_dvr'] = rdata['enable-dvr']
|
||||
# Override with configuration if set to true
|
||||
if config('disable-security-groups'):
|
||||
neutron_settings['neutron_security_groups'] = False
|
||||
@ -44,6 +48,11 @@ def _neutron_api_settings():
|
||||
return neutron_settings
|
||||
|
||||
|
||||
def use_dvr():
|
||||
api_settings = _neutron_api_settings()
|
||||
return ast.literal_eval(api_settings['enable_dvr'])
|
||||
|
||||
|
||||
class OVSPluginContext(context.NeutronContext):
|
||||
interfaces = []
|
||||
|
||||
@ -103,6 +112,7 @@ class OVSPluginContext(context.NeutronContext):
|
||||
neutron_api_settings = _neutron_api_settings()
|
||||
ovs_ctxt['neutron_security_groups'] = self.neutron_security_groups
|
||||
ovs_ctxt['l2_population'] = neutron_api_settings['l2_population']
|
||||
ovs_ctxt['distributed_routing'] = use_dvr()
|
||||
ovs_ctxt['overlay_network_type'] = \
|
||||
neutron_api_settings['overlay_network_type']
|
||||
# TODO: We need to sort out the syslog and debug/verbose options as a
|
||||
@ -111,3 +121,15 @@ class OVSPluginContext(context.NeutronContext):
|
||||
ovs_ctxt['verbose'] = conf['verbose']
|
||||
ovs_ctxt['debug'] = conf['debug']
|
||||
return ovs_ctxt
|
||||
|
||||
|
||||
class L3AgentContext(OSContextGenerator):
|
||||
|
||||
def __call__(self):
|
||||
neutron_api_settings = _neutron_api_settings()
|
||||
ctxt = {}
|
||||
if neutron_api_settings['enable_dvr'] == 'True':
|
||||
ctxt['agent_mode'] = 'dvr'
|
||||
else:
|
||||
ctxt['agent_mode'] = 'legacy'
|
||||
return ctxt
|
||||
|
@ -20,6 +20,7 @@ from charmhelpers.fetch import (
|
||||
|
||||
from neutron_ovs_utils import (
|
||||
determine_packages,
|
||||
determine_dvr_packages,
|
||||
register_configs,
|
||||
restart_map,
|
||||
)
|
||||
@ -41,6 +42,8 @@ def install():
|
||||
@hooks.hook('config-changed')
|
||||
@restart_on_change(restart_map())
|
||||
def config_changed():
|
||||
if determine_dvr_packages():
|
||||
apt_install(determine_dvr_packages(), fatal=True)
|
||||
CONFIGS.write_all()
|
||||
|
||||
|
||||
|
@ -12,6 +12,8 @@ NOVA_CONF_DIR = "/etc/nova"
|
||||
NEUTRON_CONF_DIR = "/etc/neutron"
|
||||
NEUTRON_CONF = '%s/neutron.conf' % NEUTRON_CONF_DIR
|
||||
NEUTRON_DEFAULT = '/etc/default/neutron-server'
|
||||
NEUTRON_L3_AGENT_CONF = "/etc/neutron/l3_agent.ini"
|
||||
NEUTRON_FWAAS_CONF = "/etc/neutron/fwaas_driver.ini"
|
||||
ML2_CONF = '%s/plugins/ml2/ml2_conf.ini' % NEUTRON_CONF_DIR
|
||||
|
||||
BASE_RESOURCE_MAP = OrderedDict([
|
||||
@ -24,12 +26,29 @@ BASE_RESOURCE_MAP = OrderedDict([
|
||||
'services': ['neutron-plugin-openvswitch-agent'],
|
||||
'contexts': [neutron_ovs_context.OVSPluginContext()],
|
||||
}),
|
||||
(NEUTRON_L3_AGENT_CONF, {
|
||||
'services': ['neutron-vpn-agent'],
|
||||
'contexts': [neutron_ovs_context.L3AgentContext()],
|
||||
}),
|
||||
(NEUTRON_FWAAS_CONF, {
|
||||
'services': ['neutron-vpn-agent'],
|
||||
'contexts': [neutron_ovs_context.L3AgentContext()],
|
||||
}),
|
||||
])
|
||||
TEMPLATES = 'templates/'
|
||||
|
||||
|
||||
def determine_dvr_packages():
|
||||
pkgs = []
|
||||
if neutron_ovs_context.use_dvr():
|
||||
pkgs = 'neutron-vpn-agent'
|
||||
return pkgs
|
||||
|
||||
|
||||
def determine_packages():
|
||||
return neutron_plugin_attribute('ovs', 'packages', 'neutron')
|
||||
pkgs = neutron_plugin_attribute('ovs', 'packages', 'neutron')
|
||||
pkgs.extend(determine_dvr_packages())
|
||||
return pkgs
|
||||
|
||||
|
||||
def register_configs(release=None):
|
||||
@ -47,6 +66,8 @@ def resource_map():
|
||||
hook execution.
|
||||
'''
|
||||
resource_map = deepcopy(BASE_RESOURCE_MAP)
|
||||
if not neutron_ovs_context.use_dvr():
|
||||
resource_map.pop(NEUTRON_L3_AGENT_CONF)
|
||||
return resource_map
|
||||
|
||||
|
||||
|
7
templates/juno/fwaas_driver.ini
Normal file
7
templates/juno/fwaas_driver.ini
Normal file
@ -0,0 +1,7 @@
|
||||
###############################################################################
|
||||
# [ WARNING ]
|
||||
# Configuration file maintained by Juju. Local changes may be overwritten.
|
||||
###############################################################################
|
||||
[fwaas]
|
||||
driver = neutron.services.firewall.drivers.linux.iptables_fwaas.IptablesFwaasDriver
|
||||
enabled = True
|
7
templates/juno/l3_agent.ini
Normal file
7
templates/juno/l3_agent.ini
Normal file
@ -0,0 +1,7 @@
|
||||
###############################################################################
|
||||
# [ WARNING ]
|
||||
# Configuration file maintained by Juju. Local changes may be overwritten.
|
||||
###############################################################################
|
||||
[DEFAULT]
|
||||
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
|
||||
agent_mode = {{ agent_mode }}
|
40
templates/juno/ml2_conf.ini
Normal file
40
templates/juno/ml2_conf.ini
Normal file
@ -0,0 +1,40 @@
|
||||
# icehouse
|
||||
###############################################################################
|
||||
# [ WARNING ]
|
||||
# Configuration file maintained by Juju. Local changes may be overwritten.
|
||||
# Config managed by neutron-openvswitch charm
|
||||
###############################################################################
|
||||
[ml2]
|
||||
type_drivers = gre,vxlan,vlan,flat
|
||||
tenant_network_types = gre,vxlan,vlan,flat
|
||||
mechanism_drivers = openvswitch,hyperv,l2population
|
||||
|
||||
[ml2_type_gre]
|
||||
tunnel_id_ranges = 1:1000
|
||||
|
||||
[ml2_type_vxlan]
|
||||
vni_ranges = 1001:2000
|
||||
|
||||
[ml2_type_vlan]
|
||||
network_vlan_ranges = physnet1:1000:2000
|
||||
|
||||
[ml2_type_flat]
|
||||
flat_networks = physnet1
|
||||
|
||||
[ovs]
|
||||
enable_tunneling = True
|
||||
local_ip = {{ local_ip }}
|
||||
bridge_mappings = physnet1:br-data
|
||||
|
||||
[agent]
|
||||
tunnel_types = {{ overlay_network_type }}
|
||||
l2_population = {{ l2_population }}
|
||||
enable_distributed_routing = {{ distributed_routing }}
|
||||
|
||||
[securitygroup]
|
||||
{% if neutron_security_groups -%}
|
||||
enable_security_group = True
|
||||
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
|
||||
{% else -%}
|
||||
enable_security_group = False
|
||||
{% endif -%}
|
Loading…
Reference in New Issue
Block a user