Networking OVN Puppet Module
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

181 lines
5.8 KiB

  1. # ovn controller
  2. # == Class: ovn::controller
  3. #
  4. # installs ovn and starts the ovn-controller service
  5. #
  6. # === Parameters:
  7. #
  8. # [*ovn_remote*]
  9. # (Required) URL of the remote ovn southbound db.
  10. # Example: 'tcp:127.0.0.1:6642'
  11. #
  12. # [*ovn_encap_type*]
  13. # (Optional) The encapsulation type to be used
  14. # Defaults to 'geneve'
  15. #
  16. # [*ovn_encap_ip*]
  17. # (Required) IP address of the hypervisor(in which this module is installed) to which
  18. # the other controllers would use to create a tunnel to this controller
  19. #
  20. # [*ovn_bridge_mappings*]
  21. # (optional) List of <ovn-network-name>:<bridge-name>
  22. # Defaults to empty list
  23. #
  24. # [*bridge_interface_mappings*]
  25. # (optional) List of <bridge-name>:<interface-name> when doing bridge mapping
  26. # Defaults to empty list
  27. #
  28. # [*hostname*]
  29. # (optional) The hostname to use with the external id
  30. # Defaults to $::fqdn
  31. #
  32. # [*ovn_bridge*]
  33. # (optional) Name of the integration bridge.
  34. # Defaults to 'br-int'
  35. #
  36. # [*enable_hw_offload*]
  37. # (optional) Configure OVS to use
  38. # Hardware Offload. This feature is
  39. # supported from ovs 2.8.0.
  40. # Defaults to False.
  41. #
  42. # [*mac_table_size*]
  43. # Set the mac table size for the provider bridges if defined in ovn_bridge_mappings
  44. # Defaults to 50000
  45. #
  46. # [*datapath_type*]
  47. # (optional) Datapath type for ovs bridges
  48. # Defaults to $::os_service_default
  49. #
  50. # [*enable_dpdk*]
  51. # (optional) Enable or not DPDK with OVS
  52. # Defaults to false.
  53. #
  54. # [*ovn_remote_probe_interval*]
  55. # (optional) Set probe interval, based on user configuration, value is in ms
  56. # Defaults to 60000
  57. #
  58. # [*ovn_openflow_probe_interval*]
  59. # (optional) The inactivity probe interval of the OpenFlow
  60. # connection to the OpenvSwitch integration bridge, in
  61. # seconds. If the value is zero, it disables the connection keepalive feature.
  62. # If the value is nonzero, then it will be forced to a value of at least 5s.
  63. # Defaults to 60
  64. #
  65. class ovn::controller(
  66. $ovn_remote,
  67. $ovn_encap_ip,
  68. $ovn_encap_type = 'geneve',
  69. $ovn_bridge_mappings = [],
  70. $bridge_interface_mappings = [],
  71. $hostname = $::fqdn,
  72. $ovn_bridge = 'br-int',
  73. $enable_hw_offload = false,
  74. $mac_table_size = 50000,
  75. $datapath_type = $::os_service_default,
  76. $enable_dpdk = false,
  77. $ovn_remote_probe_interval = 60000,
  78. $ovn_openflow_probe_interval = 60,
  79. ) {
  80. include ::ovn::params
  81. if $enable_dpdk and is_service_default($datapath_type) {
  82. fail('Datapath type must be set when DPDK is enabled')
  83. }
  84. if $enable_dpdk {
  85. require ::vswitch::dpdk
  86. } else {
  87. require ::vswitch::ovs
  88. }
  89. include ::stdlib
  90. validate_legacy(String, 'validate_string', $ovn_remote)
  91. validate_legacy(String, 'validate_string', $ovn_encap_ip)
  92. service { 'controller':
  93. ensure => true,
  94. name => $::ovn::params::ovn_controller_service_name,
  95. hasstatus => $::ovn::params::ovn_controller_service_status,
  96. pattern => $::ovn::params::ovn_controller_service_pattern,
  97. enable => true,
  98. subscribe => Vs_config['external_ids:ovn-remote']
  99. }
  100. package { $::ovn::params::ovn_controller_package_name:
  101. ensure => present,
  102. name => $::ovn::params::ovn_controller_package_name,
  103. before => Service['controller']
  104. }
  105. $config_items = {
  106. 'external_ids:ovn-remote' => { 'value' => $ovn_remote },
  107. 'external_ids:ovn-encap-type' => { 'value' => $ovn_encap_type },
  108. 'external_ids:ovn-encap-ip' => { 'value' => $ovn_encap_ip },
  109. 'external_ids:hostname' => { 'value' => $hostname },
  110. 'external_ids:ovn-bridge' => { 'value' => $ovn_bridge },
  111. 'external_ids:ovn-remote-probe-interval' => { 'value' => "${ovn_remote_probe_interval}" },
  112. 'external_ids:ovn-openflow-probe-interval' => { 'value' => "${ovn_openflow_probe_interval}" },
  113. }
  114. if !empty($ovn_bridge_mappings) {
  115. $bridge_items = {
  116. 'external_ids:ovn-bridge-mappings' => { 'value' => join(any2array($ovn_bridge_mappings), ',') }
  117. }
  118. ovn::controller::bridge { $ovn_bridge_mappings:
  119. before => Service['controller'],
  120. require => Service['openvswitch']
  121. }
  122. ovn::controller::port { $bridge_interface_mappings:
  123. before => Service['controller'],
  124. require => Service['openvswitch']
  125. }
  126. } else {
  127. $bridge_items = {}
  128. }
  129. if $enable_hw_offload {
  130. $hw_offload = { 'other_config:hw-offload' => { 'value' => bool2str($enable_hw_offload) } }
  131. }else {
  132. $hw_offload = {}
  133. }
  134. if ! is_service_default($datapath_type) {
  135. $datapath_config = { 'external_ids:ovn-bridge-datapath-type' => { 'value' => $datapath_type } }
  136. } else {
  137. $datapath_config = {}
  138. }
  139. create_resources('vs_config', merge($config_items, $bridge_items, $hw_offload, $datapath_config))
  140. Service['openvswitch'] -> Vs_config<||> -> Service['controller']
  141. if !empty($ovn_bridge_mappings) {
  142. # For each provider bridge, set the mac table size.
  143. $ovn_bridge_mappings.each |String $mappings| {
  144. $mapping = split($mappings, ':')
  145. $br = $mapping[1]
  146. if !empty($br) {
  147. # TODO(numans): Right now puppet-vswitch's vs_bridge doesn't support
  148. # setting the column 'other-config' for the Bridge table.
  149. # Switch to using vs_bridge once the support is available.
  150. exec { $br:
  151. command => "ovs-vsctl --timeout=5 set Bridge ${br} other-config:mac-table-size=${mac_table_size}",
  152. unless => "ovs-vsctl get bridge ${br} other-config:mac-table-size | grep -q -w ${mac_table_size}",
  153. path => '/usr/sbin:/usr/bin:/sbin:/bin',
  154. onlyif => "ovs-vsctl br-exists ${br}",
  155. require => [ Service['openvswitch'], Vs_bridge[$br] ],
  156. }
  157. }
  158. }
  159. } else {
  160. # ovn-bridge-mappings is not defined. Clear the existing value if configured.
  161. vs_config { 'external_ids:ovn-bridge-mappings':
  162. ensure => absent,
  163. require => Service['openvswitch']
  164. }
  165. }
  166. }