Add ability to define bridge type for containers

This change allows to define `container_bridge_type` among provider_networks to
provide type of bridge being used (ie ovs).

Documentaion on usage will be provided in following patch.

Needed-By: https://review.opendev.org/c/openstack/openstack-ansible-lxc_container_create/+/837734
Change-Id: I4f65c13a7dd16a66b2b14ae545516533f5ec69e1
This commit is contained in:
Dmitriy Rabotyagov 2022-04-13 18:08:19 +02:00 committed by Dmitriy Rabotyagov
parent 8a27a3c8d3
commit 21dd4e6c5d
4 changed files with 26 additions and 13 deletions

View File

@ -26,20 +26,21 @@ the same multiport network card for the same bonded interface, because a
network card failure affects both of the physical network interfaces used by network card failure affects both of the physical network interfaces used by
the bond. the bond.
Linux bridges Linux bridges/switches
~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~
The combination of containers and flexible deployment options requires The combination of containers and flexible deployment options requires
implementation of advanced Linux networking features, such as bridges and implementation of advanced Linux networking features, such as bridges,
namespaces. switches and namespaces.
* Bridges provide layer 2 connectivity (similar to switches) among * Bridges/switches provide layer 2 connectivity (similar to switches) among
physical, logical, and virtual network interfaces within a host. After physical, logical, and virtual network interfaces within a host. After
a bridge is created, the network interfaces are virtually plugged in to a bridge/switch is created, the network interfaces are virtually plugged
it. in to it.
OpenStack-Ansible uses bridges to connect physical and logical network OpenStack-Ansible can use linux bridges or openvswitches to connect
interfaces on the host to virtual network interfaces within containers. physical and logical network interfaces on the host to virtual network
interfaces within containers.
* Namespaces provide logically separate layer 3 environments (similar to * Namespaces provide logically separate layer 3 environments (similar to
routers) within a host. Namespaces use virtual interfaces to connect routers) within a host. Namespaces use virtual interfaces to connect

View File

@ -48,6 +48,7 @@ network:
interfaces: interfaces:
- bond0.20 - bond0.20
mtu: 9000 mtu: 9000
openvswitch: {}
br-vxlan: br-vxlan:
addresses: addresses:
- 172.29.240.10/22 - 172.29.240.10/22

View File

@ -138,6 +138,11 @@
# Name of unique bridge on target hosts to use for this network. Typical # Name of unique bridge on target hosts to use for this network. Typical
# values include 'br-mgmt', 'br-storage', 'br-vlan', 'br-vxlan', etc. # values include 'br-mgmt', 'br-storage', 'br-vlan', 'br-vxlan', etc.
# #
# Option: container_bridge_type (optional, string)
# Type of container_bridge on target hosts. This option should only set
# to "openvswitch" when the container_bridge is set up with openvswitch.
# The default value is undefined, which means bridge type is linux bridge.
#
# Option: container_interface (required, string) # Option: container_interface (required, string)
# Name of unique interface in containers to use for this network. # Name of unique interface in containers to use for this network.
# Typical values include 'eth1', 'eth2', etc. This option is OPTIONAL # Typical values include 'eth1', 'eth2', etc. This option is OPTIONAL

View File

@ -527,7 +527,7 @@ def skel_load(skeleton, inventory):
def network_entry(is_metal, interface, def network_entry(is_metal, interface,
bridge=None, net_type=None, net_mtu=None): bridge=None, bridge_type=None, net_type=None, net_mtu=None):
"""Return a network entry for a container.""" """Return a network entry for a container."""
# TODO(cloudnull) After a few releases this conditional should be # TODO(cloudnull) After a few releases this conditional should be
@ -542,6 +542,9 @@ def network_entry(is_metal, interface,
if bridge: if bridge:
_network['bridge'] = bridge _network['bridge'] = bridge
if bridge_type:
_network['bridge_type'] = bridge_type
if net_type: if net_type:
_network['type'] = net_type _network['type'] = net_type
@ -552,9 +555,9 @@ def network_entry(is_metal, interface,
def _add_additional_networks(key, inventory, ip_q, q_name, netmask, interface, def _add_additional_networks(key, inventory, ip_q, q_name, netmask, interface,
bridge, net_type, net_mtu, user_config, bridge, bridge_type, net_type, net_mtu,
is_container_address, static_routes, gateway, user_config, is_container_address, static_routes,
reference_group, address_prefix): gateway, reference_group, address_prefix):
"""Process additional ip adds and append then to hosts as needed. """Process additional ip adds and append then to hosts as needed.
If the host is found to be "is_metal" it will be marked as "on_metal" If the host is found to be "is_metal" it will be marked as "on_metal"
@ -588,6 +591,7 @@ def _add_additional_networks(key, inventory, ip_q, q_name, netmask, interface,
netmask, netmask,
interface, interface,
bridge, bridge,
bridge_type,
net_type, net_type,
net_mtu, net_mtu,
user_config, user_config,
@ -640,6 +644,7 @@ def _add_additional_networks(key, inventory, ip_q, q_name, netmask, interface,
is_metal, is_metal,
interface, interface,
bridge, bridge,
bridge_type,
net_type, net_type,
net_mtu net_mtu
) )
@ -766,6 +771,7 @@ def container_skel_load(container_skel, inventory, config):
netmask=netmask, netmask=netmask,
interface=p_net.get('container_interface'), interface=p_net.get('container_interface'),
bridge=p_net.get('container_bridge'), bridge=p_net.get('container_bridge'),
bridge_type=p_net.get('container_bridge_type'),
net_type=p_net.get('container_type'), net_type=p_net.get('container_type'),
net_mtu=p_net.get('container_mtu'), net_mtu=p_net.get('container_mtu'),
user_config=config, user_config=config,