Saltstack Official Linux Formula
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

216 lines
6.9KB

  1. {%- from "linux/map.jinja" import network with context %}
  2. {%- from "linux/map.jinja" import system with context %}
  3. {%- if network.dpdk.enabled %}
  4. linux_dpdk_pkgs:
  5. pkg.installed:
  6. - pkgs: {{ network.dpdk_pkgs }}
  7. linux_dpdk_kernel_module:
  8. kmod.present:
  9. - name: {{ network.dpdk.driver }}
  10. - persist: true
  11. - require:
  12. - pkg: linux_dpdk_pkgs
  13. - require_in:
  14. - service: linux_network_dpdk_service
  15. /etc/dpdk/interfaces:
  16. file.managed:
  17. - source: salt://linux/files/dpdk_interfaces
  18. - template: jinja
  19. - user: root
  20. - group: root
  21. - mode: 644
  22. - require:
  23. - pkg: linux_dpdk_pkgs
  24. linux_network_dpdk_service:
  25. service.running:
  26. - enable: true
  27. - name: dpdk
  28. - watch:
  29. - file: /etc/dpdk/interfaces
  30. {%- if network.openvswitch is defined %}
  31. openvswitch_dpdk_pkgs:
  32. pkg.installed:
  33. - pkgs:
  34. - openvswitch-switch-dpdk
  35. - openvswitch-switch
  36. - bridge-utils
  37. {# create drop-in dpdk dependency for openvswitch-switch (ovsdb-server) #}
  38. /etc/systemd/system/openvswitch-switch.service.d/dpdk.conf:
  39. file.managed:
  40. - makedirs: true
  41. - require:
  42. - pkg: openvswitch_dpdk_pkgs
  43. - contents: |
  44. [Unit]
  45. Requires=dpdk.service
  46. After=dpdk.service
  47. linux_network_dpdk_ovs_service:
  48. cmd.run:
  49. - name: "ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-init=true"
  50. - require:
  51. - service: linux_network_dpdk_service
  52. - unless: 'ovs-vsctl get Open_vSwitch . other_config | grep "dpdk-init=\"true\""'
  53. {%- set ovs_options = [
  54. "pmd-cpu-mask=\""+network.openvswitch.pmd_cpu_mask+"\"",
  55. "dpdk-socket-mem=\""+network.openvswitch.dpdk_socket_mem+"\"",
  56. "dpdk-lcore-mask=\""+network.openvswitch.dpdk_lcore_mask+"\"",
  57. "dpdk-extra=\"-n "+network.openvswitch.memory_channels+" --vhost-owner libvirt-qemu:kvm --vhost-perm 0664\""
  58. ]
  59. %}
  60. {%- if network.openvswitch.get('vhost_socket_dir',{}).get('path') %}
  61. {%- do ovs_options.append("vhost-sock-dir=\""+network.openvswitch.vhost_socket_dir.path+"\"") %}
  62. {%- endif %}
  63. {%- for option in ovs_options %}
  64. linux_network_dpdk_ovs_option_{{ option }}:
  65. cmd.run:
  66. - name: 'ovs-vsctl set Open_vSwitch . other_config:{{ option }}'
  67. - watch_in:
  68. - service: service_openvswitch
  69. - require:
  70. - cmd: linux_network_dpdk_ovs_service
  71. - unless: |
  72. ovs-vsctl get Open_vSwitch . other_config | grep '{{ option }}'
  73. {%- endfor %}
  74. openvswitch_dpdk_ovs_alternative:
  75. alternatives.remove:
  76. - name: ovs-vswitchd
  77. - path: /usr/lib/openvswitch-switch/ovs-vswitchd
  78. - require:
  79. - pkg: openvswitch_dpdk_pkgs
  80. - watch_in:
  81. - service: service_openvswitch
  82. service_openvswitch:
  83. service.running:
  84. - name: openvswitch-switch
  85. - enable: true
  86. - watch:
  87. - cmd: linux_network_dpdk_ovs_service
  88. {%- endif %}
  89. {%- for interface_name, interface in network.interface.items() if interface.get('enabled', True) %}
  90. {%- if interface.type == "dpdk_ovs_bond" %}
  91. {%- set bond_interfaces = {} %}
  92. {%- for iface_name, iface in network.interface.items() if iface.get('enabled', True) and iface.get('bond',"") == interface_name %}
  93. {#- Get list of child interfaces #}
  94. {%- do bond_interfaces.update({iface_name: iface}) %}
  95. {%- endfor %}
  96. linux_network_dpdk_bond_interface_{{ interface_name }}:
  97. cmd.run:
  98. - name: "ovs-vsctl add-bond {{ interface.bridge }} {{ interface_name }} {{ bond_interfaces.keys()|join(' ') }} {% for iface_name, iface in bond_interfaces.items() %}-- set Interface {{ iface_name }} type=dpdk options:dpdk-devargs={{ iface.pci }} {% endfor %}"
  99. - unless: "ovs-vsctl show | grep {{ interface_name }}"
  100. - require:
  101. - cmd: linux_network_dpdk_bridge_interface_{{ interface.bridge }}
  102. linux_network_dpdk_bond_mode_{{ interface_name }}:
  103. cmd.run:
  104. - name: "ovs-vsctl set port {{ interface_name }} bond_mode={{ interface.mode }}"
  105. - unless: "ovs-appctl bond/show {{ interface_name }} | grep {{ interface.mode }}"
  106. - require:
  107. - cmd: linux_network_dpdk_bond_interface_{{ interface_name }}
  108. {%- elif interface.type == 'dpdk_ovs_bridge' %}
  109. linux_network_dpdk_bridge_interface_{{ interface_name }}:
  110. cmd.run:
  111. - name: "ovs-vsctl add-br {{ interface_name }} -- set bridge {{ interface_name }} datapath_type=netdev{% if interface.tag is defined %} -- set port {{ interface_name }} tag={{ interface.tag }}{% endif %}"
  112. - unless: "ovs-vsctl show | grep {{ interface_name }}"
  113. {# OVS dpdk needs ip address for vxlan termination on bridge br-prv #}
  114. {%- if interface.address is defined %}
  115. {# create override for openvswitch dependency for dpdk br-prv #}
  116. /etc/systemd/system/ifup@{{ interface_name }}.service.d/override.conf:
  117. file.managed:
  118. - makedirs: true
  119. - require:
  120. - cmd: linux_network_dpdk_bridge_interface_{{ interface_name }}
  121. - contents: |
  122. [Unit]
  123. Requires=openvswitch-switch.service
  124. After=openvswitch-switch.service
  125. {# enforce ip address and mtu for ovs dpdk br-prv #}
  126. /etc/network/interfaces.d/ifcfg-{{ interface_name }}:
  127. file.managed:
  128. - contents: |
  129. auto {{ interface_name }}
  130. iface {{ interface_name }} inet static
  131. address {{ interface.address }}
  132. netmask {{ interface.netmask }}
  133. {%- if interface.mtu is defined %}
  134. mtu {{ interface.mtu }}
  135. {%- endif %}
  136. - require:
  137. - file: /etc/systemd/system/ifup@{{ interface_name }}.service.d/override.conf
  138. {%- endif %}
  139. {%- elif interface.type == 'dpdk_ovs_port' and interface.bridge is defined %}
  140. linux_network_dpdk_bridge_port_interface_{{ interface_name }}:
  141. cmd.run:
  142. - name: "ovs-vsctl add-port {{ interface.bridge }} dpdk0 -- set Interface dpdk0 type=dpdk options:dpdk-devargs={{ interface.pci }}"
  143. - unless: "ovs-vsctl show | grep dpdk0"
  144. - require:
  145. - cmd: linux_network_dpdk_bridge_interface_{{ interface.bridge }}
  146. {%- endif %}
  147. {# Multiqueue n_rxq, pmd_rxq_affinity and mtu setup on interfaces #}
  148. {%- if interface.type == 'dpdk_ovs_port' %}
  149. {%- if interface.n_rxq is defined %}
  150. linux_network_dpdk_bridge_port_interface_n_rxq_{{ interface_name }}:
  151. cmd.run:
  152. - name: "ovs-vsctl set Interface {{ interface_name }} options:n_rxq={{ interface.n_rxq }} "
  153. - unless: |
  154. ovs-vsctl get Interface {{ interface_name }} options | grep 'n_rxq="{{ interface.n_rxq }}"'
  155. {%- endif %}
  156. {%- if interface.pmd_rxq_affinity is defined %}
  157. linux_network_dpdk_bridge_port_interface_pmd_rxq_affinity_{{ interface_name }}:
  158. cmd.run:
  159. - name: "ovs-vsctl set Interface {{ interface_name }} other_config:pmd-rxq-affinity={{ interface.pmd_rxq_affinity }} "
  160. - unless: |
  161. ovs-vsctl get Interface {{ interface_name }} other_config | grep 'pmd-rxq-affinity="{{ interface.pmd_rxq_affinity }}"'
  162. {%- endif %}
  163. {%- if interface.mtu is defined %}
  164. {# MTU ovs dpdk setup on interfaces #}
  165. linux_network_dpdk_bridge_port_interface_mtu_{{ interface_name }}:
  166. cmd.run:
  167. - name: "ovs-vsctl set Interface {{ interface_name }} mtu_request={{ interface.mtu }} "
  168. - unless: "ovs-vsctl get Interface {{ interface_name }} mtu_request | grep {{ interface.mtu }}"
  169. {%- endif %}
  170. {%- endif %}
  171. {%- endfor %}
  172. {%- endif %}