Update provider networks plugin to support multiple network mappings

This patch updates the provider networks plugin by adding support
for network interface to bridge mappings. For each flat/vlan provider
network, a network_interface can be defined that will be added to an OVS
provider bridge automatically. This supercedes the network_interface override
for OVS-based deployments, including OVS, OVS w/ DVR, and OVN, that was
only available outside of the plugin.

Change-Id: I99d95ab103f9d64726a809eb81db69e0b2b18ffb
This commit is contained in:
James Denton 2018-12-20 14:52:02 +00:00
parent 37f4125234
commit 7fd6dd2112
1 changed files with 29 additions and 2 deletions

View File

@ -23,7 +23,7 @@ from ansible.module_utils.basic import *
DOCUMENTATION = """
---
module: provider_networks
version_added: "1.8.5"
version_added: "1.8.6"
short_description:
- Parse a list of networks and return data that Ansible can use
description:
@ -100,6 +100,16 @@ EXAMPLES = """
# group_binds:
# - neutron_linuxbridge_agent
# - network:
# container_bridge: "br-provider"
# container_type: "veth"
# container_interface: "eth11"
# network_interface: "bond1"
# type: "vlan"
# range: "1:1, 101:101"
# net_name: "physnet1"
# group_binds:
# - neutron_openvswitch_agent
# - network:
# container_bridge: "br-storage"
# container_type: "veth"
# container_interface: "eth2"
@ -185,6 +195,7 @@ class ProviderNetworksParsing(object):
self.network_mappings = list()
self.network_types = list()
self.network_sriov_mappings = list()
self.network_interface_mappings = list()
def load_networks(self, provider_networks, is_metal=False,
bind_prefix=None, group_names=None):
@ -266,6 +277,18 @@ class ProviderNetworksParsing(object):
)
)
# Builds a list of provider bridge to physical
# interface mappings and is used when adding OVS
# ports to bridges
if 'network_interface' in net['network']:
self.network_interface_mappings.append(
'%s:%s' % (
net['network']['container_bridge'],
net['network']['network_interface']
)
)
# SR-IOV interface mappings
if 'sriov_host_interfaces' in net['network']:
host_interfaces = \
net['network']['sriov_host_interfaces']
@ -329,7 +352,11 @@ def main():
'network_mappings_list': pnp.network_mappings,
'network_types': ','.join(pnp.network_types),
'network_sriov_mappings': ','.join(pnp.network_sriov_mappings),
'network_sriov_mappings_list': pnp.network_sriov_mappings
'network_sriov_mappings_list': pnp.network_sriov_mappings,
'network_interface_mappings': ','.join(
pnp.network_interface_mappings
),
'network_interface_mappings_list': pnp.network_interface_mappings
}
module.exit_json(changed=True, **resp)