Support configuration of controller ports for neutron ML2 generic switch driver

We use the switch interface configuration to provide a list of interfaces
to the neutron ML2 generic switch driver to be configured as trunk ports
in each neutron network. These interfaces correspond to the controllers
by default, which need access to all of the networks in order to provide
services such as DHCP and routing.

Related-Bug: #1690115
This commit is contained in:
Mark Goddard 2017-05-11 19:09:43 +01:00
parent 6e64a78f94
commit eb8a42e911
4 changed files with 63 additions and 6 deletions

View File

@ -0,0 +1,40 @@
# Copyright (c) 2017 StackHPC Ltd.
#
# 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.
import six
def switch_interface_config_select_description(switch_interface_config, descriptions):
"""Select and return all switch interfaces matching requested descriptions.
:param switch_interface_config: Switch interface configuration dict
:param descriptions: String or list of strings - descriptions to match
"""
if isinstance(descriptions, six.string_types):
descriptions = [descriptions]
return {
name: config
for name, config in switch_interface_config.items()
if config.get('description') in descriptions
}
class FilterModule(object):
"""Switch filters."""
def filters(self):
return {
'switch_interface_config_select_description': switch_interface_config_select_description,
}

View File

@ -46,3 +46,10 @@ kolla_neutron_ml2_generic_switches: []
# key_file: not currently supported
# secret: not currently supported
kolla_neutron_ml2_generic_switch_hosts: []
# List of Ansible hosts whose switch interfaces are to be configured as tagged
# members of all networks managed by the genericswitch ML2 mechanism driver.
# These hosts will be matched against the description fields in the
# switch_interface_config variable for each switch to determine which
# interfaces should be configured.
kolla_neutron_ml2_generic_switch_trunk_port_hosts: "{{ groups['controllers'] }}"

View File

@ -54,12 +54,19 @@
- name: Update a fact containing switches for use by Neutron ML2 genericswitch driver
set_fact:
kolla_neutron_ml2_generic_switches: >
{{ kolla_neutron_ml2_generic_switches +
[{'name': item,
'device_type': switch_type_to_device_type[hostvars[item].switch_type],
'ip': hostvars[item].ansible_host,
'username': hostvars[item].ansible_user,
'password': hostvars[item].ansible_ssh_pass}] }}
{{
kolla_neutron_ml2_generic_switches +
[{
'name': item,
'device_type': switch_type_to_device_type[hostvars[item].switch_type],
'ip': hostvars[item].ansible_host,
'username': hostvars[item].ansible_user,
'password': hostvars[item].ansible_ssh_pass,
'ngs_trunk_ports': (
hostvars[item].switch_interface_config |
switch_interface_config_select_description(kolla_neutron_ml2_generic_switch_trunk_port_hosts)).keys() | join(',')
}]
}}
with_items: "{{ kolla_neutron_ml2_generic_switch_hosts }}"
tags:
- config

View File

@ -32,6 +32,9 @@ key_file = {{ switch.key_file }}
{% if switch.secret is defined %}
secret = {{ switch.secret }}
{% endif %}
{% if switch.ngs_trunk_ports is defined %}
ngs_trunk_ports = {{ switch.ngs_trunk_ports }}
{% endif %}
{% endfor %}