Saltstack Official Linux Formula
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

135 lines
4.3KB

  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. {%- elif interface.type == 'dpdk_ovs_port' and interface.bridge is defined %}
  92. linux_network_dpdk_bridge_port_interface_{{ interface_name }}:
  93. cmd.run:
  94. - name: "ovs-vsctl add-port {{ interface.bridge }} dpdk0 -- set Interface dpdk0 type=dpdk options:dpdk-devargs={{ interface.pci }}"
  95. - unless: "ovs-vsctl show | grep dpdk0"
  96. - require:
  97. - cmd: linux_network_dpdk_bridge_interface_{{ interface.bridge }}
  98. {# Multiqueue n_rxq setup on interfaces #}
  99. {%- elif interface.type == 'dpdk_ovs_port' and interface.n_rxq is defined %}
  100. linux_network_dpdk_bridge_port_interface_n_rxq_{{ interface_name }}:
  101. cmd.run:
  102. - name: "ovs-vsctl set Interface {{ interface_name }} options:n_rxq={{ interface.n_rxq }} "
  103. - unless: |
  104. ovs-vsctl get Interface {{ interface_name }} options | grep 'n_rxq="{{ interface.n_rxq }}"'
  105. {%- endif %}
  106. {%- endfor %}
  107. {%- endif %}