Saltstack Official Linux Formula
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

189 lines
6.2KB

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