Add support for bridge mappings

When OVN virtual networks wants to access the provider networks it does
so with the help of a special port type 'localnet'. For the localnet ports
to be present in the agent side, the agent has to carry some details
in the vswitch DB as well a bridge has to be setup for the same.

This patch help to setup up the bridge for provider network mapping and to
add appropriate interfaces to the bridge

Change-Id: Ia6d66fa954571328c0ac3542af17303def382c1a
This commit is contained in:
Babu Shanmugam 2016-11-18 11:56:14 +00:00 committed by Matthew J. Black
parent 4652a2554d
commit c3e5717561
5 changed files with 115 additions and 47 deletions

View File

@ -6,7 +6,8 @@
# === Parameters:
#
# [*ovn_remote*]
# (Required) URL of the remote ovsdb-server that manages ovn-nb and ovn-sb dbs
# (Required) URL of the remote ovn southbound db.
# Example: 'tcp:127.0.0.1:6642'
#
# [*ovn_encap_type*]
# (Optional) The encapsulation type to be used
@ -16,10 +17,20 @@
# (Required) IP address of the hypervisor(in which this module is installed) to which
# the other controllers would use to create a tunnel to this controller
#
# [*ovn_bridge_mappings*]
# (optional) List of <ovn-network-name>:<bridge-name>
# Defaults to empty list
#
# [*bridge_interface_mappings*]
# (optional) List of <bridge-name>:<interface-name> when doing bridge mapping
# Defaults to empty list
#
class ovn::controller(
$ovn_remote,
$ovn_encap_ip,
$ovn_encap_type = 'geneve',
$ovn_bridge_mappings = [],
$bridge_interface_mappings = []
) {
include ::ovn::params
include ::vswitch::ovs
@ -34,9 +45,7 @@ class ovn::controller(
hasstatus => $::ovn::params::ovn_controller_service_status,
pattern => $::ovn::params::ovn_controller_service_pattern,
enable => true,
require => [Vs_config['external_ids:ovn-remote'],
Vs_config['external_ids:ovn-encap-type'],
Vs_config['external_ids:ovn-encap-ip']]
subscribe => Vs_config['external_ids:ovn-remote']
}
package { $::ovn::params::ovn_controller_package_name:
@ -45,21 +54,30 @@ class ovn::controller(
before => Service['controller']
}
vs_config { 'external_ids:ovn-remote':
ensure => present,
value => $ovn_remote,
require => Service['openvswitch'],
$config_items = {
'external_ids:ovn-remote' => { 'value' => $ovn_remote },
'external_ids:ovn-encap-type' => { 'value' => $ovn_encap_type },
'external_ids:ovn-encap-ip' => { 'value' => $ovn_encap_ip },
'external_ids:hostname' => { 'value' => $::fqdn },
}
vs_config { 'external_ids:ovn-encap-type':
ensure => present,
value => $ovn_encap_type,
require => Service['openvswitch'],
if !empty($ovn_bridge_mappings) {
$bridge_items = {
'external_ids:ovn-bridge-mappings' => { 'value' => join(any2array($ovn_bridge_mappings), ',') }
}
vs_config { 'external_ids:ovn-encap-ip':
ensure => present,
value => $ovn_encap_ip,
require => Service['openvswitch'],
ovn::controller::bridge { $ovn_bridge_mappings:
before => Service['controller'],
require => Service['openvswitch']
}
ovn::controller::port { $bridge_interface_mappings:
before => Service['controller'],
require => Service['openvswitch']
}
} else {
$bridge_items = {}
}
create_resources('vs_config', merge($config_items, $bridge_items))
Service['openvswitch'] -> Vs_config<||> -> Service['controller']
}

View File

@ -0,0 +1,14 @@
# ovn controller bridge settings
# == Define: ovn::controller::bridge
#
# Bridge settings for ovn controller bridge mappings
# $name is OVN bridge mapping in the format network-name:bridge-name
#
define ovn::controller::bridge {
$map_split = split($name, ':')
$bridge = $map_split[1]
vs_bridge { $bridge:
ensure => present,
external_ids => "bridge-id=${bridge}"
}
}

View File

@ -0,0 +1,15 @@
# ovn controller bridge-port settings
# == Define: ovn::controller::port
#
# Bridge-interface setting for ovn bridge mapping
# $name should be the mapping in the format <bridge-name>:<interface-name>
#
define ovn::controller::port {
$map_split = split($name, ':')
$bridge = $map_split[0]
$iface = $map_split[1]
vs_port { $iface:
ensure => present,
bridge => $bridge
}
}

View File

@ -0,0 +1,5 @@
---
features:
- Setup up the bridge for provider network mapping and to add appropriate interfaces to the bridge.
issues:
- Documentation for ovn_remote has been update to reflect what values are expected to be passed into it.

View File

@ -5,7 +5,9 @@ describe 'ovn::controller' do
let :params do
{ :ovn_remote => 'tcp:x.x.x.x:5000',
:ovn_encap_type => 'geneve',
:ovn_encap_ip => '1.2.3.4'
:ovn_encap_ip => '1.2.3.4',
:ovn_bridge_mappings => ['physnet-1:br-1'],
:bridge_interface_mappings => ['br-1:eth1']
}
end
@ -38,20 +40,34 @@ describe 'ovn::controller' do
it 'configures ovsdb' do
is_expected.to contain_vs_config('external_ids:ovn-remote').with(
:ensure => 'present',
:value => params[:ovn_remote],
:require => 'Service[openvswitch]'
)
is_expected.to contain_vs_config('external_ids:ovn-encap-type').with(
:ensure => 'present',
:value => params[:ovn_encap_type],
:require => 'Service[openvswitch]'
)
is_expected.to contain_vs_config('external_ids:ovn-encap-ip').with(
:ensure => 'present',
:value => params[:ovn_encap_ip],
)
is_expected.to contain_vs_config('external_ids:hostname').with(
:value => 'foo.example.com',
)
end
it 'configures bridge mappings' do
is_expected.to contain_vs_config('external_ids:ovn-bridge-mappings').with(
:value => 'physnet-1:br-1',
)
is_expected.to contain_ovn__controller__bridge(params[:ovn_bridge_mappings].join(',')).with(
:before => 'Service[controller]',
:require => 'Service[openvswitch]'
)
is_expected.to contain_ovn__controller__port(params[:bridge_interface_mappings].join(',')).with(
:before => 'Service[controller]',
:require => 'Service[openvswitch]'
)
end