Support polling-interval rpc-response-timeout and report-interval

These options are set in the neutron-api charm centrally, and
this patch allows neutron-openvswitch charm to continue doing:

1, polling_interval
   Just used by neutron l2 agents, so neutron-openvswitch charm
   gets it via it's relations and set it in [agent] of ml2_conf.ini
   or openvswitch_agent.ini(>=Mitaka)

2, rpc_response_timeout
   Used by all neutron agents, so both neutron-gateway charm and
   neutron-openvswitch charm get it via it's relations and set it
   in [default] of neutron.conf

3, report_interval
   Used by all neutron agents, so both neutron-gateway charm and
   neutron-openvswitch charm get it via it's relations and set it
   in [agent] of neutron.conf

Change-Id: I76c0c75d5f3b4fdd1eb3242b53fde2e829fedca5
Partial-Bug: #1685788
This commit is contained in:
Zhang Hua 2017-07-05 11:21:33 +08:00 committed by Edward Hope-Morley
parent 3ca3910e99
commit 6b5273f415
11 changed files with 54 additions and 8 deletions

View File

@ -736,11 +736,17 @@ class ApacheSSLContext(OSContextGenerator):
return sorted(list(set(cns)))
def get_network_addresses(self):
"""For each network configured, return corresponding address and vip
(if available).
"""For each network configured, return corresponding address and
hostnamr or vip (if available).
Returns a list of tuples of the form:
[(address_in_net_a, hostname_in_net_a),
(address_in_net_b, hostname_in_net_b),
...]
or, if no hostnames(s) available:
[(address_in_net_a, vip_in_net_a),
(address_in_net_b, vip_in_net_b),
...]
@ -757,18 +763,22 @@ class ApacheSSLContext(OSContextGenerator):
else:
vips = []
for net_type in ['os-internal-network', 'os-admin-network',
'os-public-network']:
addr = get_address_in_network(config(net_type),
for net_type in ['internal', 'admin', 'public']:
net_config = config('os-{}-network'.format(net_type))
addr = get_address_in_network(net_config,
unit_get('private-address'))
if len(vips) > 1 and is_clustered():
if not config(net_type):
hostname_config = config('os-{}-hostname'.format(net_type))
if hostname_config:
addresses.append((addr, hostname_config))
elif len(vips) > 1 and is_clustered():
if not net_config:
log("Multiple networks configured but net_type "
"is None (%s)." % net_type, level=WARNING)
continue
for vip in vips:
if is_address_in_network(config(net_type), vip):
if is_address_in_network(net_config, vip):
addresses.append((addr, vip))
break
@ -1419,14 +1429,26 @@ class NeutronAPIContext(OSContextGenerator):
'rel_key': 'report-interval',
'default': 30,
},
'enable_qos': {
'rel_key': 'enable-qos',
'default': False,
},
}
ctxt = self.get_neutron_options({})
for rid in relation_ids('neutron-plugin-api'):
for unit in related_units(rid):
rdata = relation_get(rid=rid, unit=unit)
# The l2-population key is used by the context as a way of
# checking if the api service on the other end is sending data
# in a recent format.
if 'l2-population' in rdata:
ctxt.update(self.get_neutron_options(rdata))
if ctxt['enable_qos']:
ctxt['extensions'] = 'qos'
else:
ctxt['extensions'] = ''
return ctxt
def get_neutron_options(self, rdata):

View File

@ -789,6 +789,9 @@ class Hooks(object):
def charm_dir():
"""Return the root directory of the current charm"""
d = os.environ.get('JUJU_CHARM_DIR')
if d is not None:
return d
return os.environ.get('CHARM_DIR')

View File

@ -114,6 +114,10 @@ class OVSPluginContext(context.NeutronContext):
ovs_ctxt['distributed_routing'] = neutron_api_settings['enable_dvr']
ovs_ctxt['overlay_network_type'] = \
neutron_api_settings['overlay_network_type']
ovs_ctxt['polling_interval'] = neutron_api_settings['polling_interval']
ovs_ctxt['rpc_response_timeout'] = \
neutron_api_settings['rpc_response_timeout']
ovs_ctxt['report_interval'] = neutron_api_settings['report_interval']
# TODO: We need to sort out the syslog and debug/verbose options as a
# general context helper
ovs_ctxt['use_syslog'] = conf['use-syslog']

View File

@ -32,6 +32,7 @@ l2_population = {{ l2_population }}
{% if veth_mtu -%}
veth_mtu = {{ veth_mtu }}
{% endif %}
polling_interval = {{ polling_interval }}
[securitygroup]
{% if neutron_security_groups -%}

View File

@ -26,6 +26,7 @@ notification_driver = messaging
{% endif -%}
default_notification_level = INFO
notification_topics = notifications
rpc_response_timeout = {{ rpc_response_timeout }}
{% include "parts/rabbitmq" %}
@ -35,6 +36,7 @@ notification_topics = notifications
[AGENT]
root_helper = sudo neutron-rootwrap /etc/neutron/rootwrap.conf
report_interval = {{ report_interval }}
[keystone_authtoken]
signing_dir = /var/lib/neutron/keystone-signing

View File

@ -33,6 +33,7 @@ enable_distributed_routing = {{ distributed_routing }}
{% if veth_mtu -%}
veth_mtu = {{ veth_mtu }}
{% endif %}
polling_interval = {{ polling_interval }}
[securitygroup]
{% if neutron_security_groups -%}

View File

@ -25,6 +25,7 @@ auth_strategy = keystone
notification_driver = messaging
default_notification_level = INFO
notification_topics = notifications
rpc_response_timeout = {{ rpc_response_timeout }}
{% include "section-zeromq" %}
@ -36,6 +37,7 @@ notification_topics = notifications
[AGENT]
root_helper = sudo neutron-rootwrap /etc/neutron/rootwrap.conf
report_interval = {{ report_interval }}
[keystone_authtoken]
signing_dir = /var/lib/neutron/keystone-signing

View File

@ -34,6 +34,7 @@ prevent_arp_spoofing = {{ prevent_arp_spoofing }}
{% if veth_mtu -%}
veth_mtu = {{ veth_mtu }}
{% endif -%}
polling_interval = {{ polling_interval }}
[securitygroup]
{% if neutron_security_groups -%}

View File

@ -20,6 +20,7 @@ prevent_arp_spoofing = {{ prevent_arp_spoofing }}
{% if veth_mtu -%}
veth_mtu = {{ veth_mtu }}
{% endif -%}
polling_interval = {{ polling_interval }}
[securitygroup]
{% if neutron_security_groups and not enable_dpdk -%}

View File

@ -789,6 +789,9 @@ class Hooks(object):
def charm_dir():
"""Return the root directory of the current charm"""
d = os.environ.get('JUJU_CHARM_DIR')
if d is not None:
return d
return os.environ.get('CHARM_DIR')

View File

@ -170,6 +170,9 @@ class OVSPluginContextTest(CharmTestCase):
'neutron_url': 'https://127.0.0.13:9696',
'l2_population': True,
'overlay_network_type': 'gre',
'polling_interval': 2,
'rpc_response_timeout': 60,
'report_interval': 30,
'network_providers': 'physnet3,physnet4',
'bridge_mappings': 'physnet1:br-data,physnet2:br-data',
'vlan_ranges': 'physnet1:1000:1500,physnet2:2000:2500',
@ -238,6 +241,9 @@ class OVSPluginContextTest(CharmTestCase):
'neutron_url': 'https://127.0.0.13:9696',
'l2_population': True,
'overlay_network_type': 'gre',
'polling_interval': 2,
'rpc_response_timeout': 60,
'report_interval': 30,
'bridge_mappings': 'physnet1:br-data',
'vlan_ranges': 'physnet1:1000:2000',
'prevent_arp_spoofing': True,