Add sriov support in HCO
Change-Id: Idd18e3fd3d0657c11608a4f1a7af1eb40cbca3bf
This commit is contained in:
parent
6af4deb077
commit
2a6fa8610a
|
@ -1,14 +1,17 @@
|
||||||
- block:
|
- block:
|
||||||
- name: copy script
|
- name: copy script
|
||||||
|
become: yes
|
||||||
copy:
|
copy:
|
||||||
src: /opt/ansible/scripts/{{ exec_item.name }}
|
src: /opt/ansible/scripts/{{ exec_item.name }}
|
||||||
dest: ~/.
|
dest: /root
|
||||||
mode: '0755'
|
mode: '0755'
|
||||||
- name: exec script command
|
- name: exec script command
|
||||||
command: "~/{{ exec_item.name }} {{ exec_item.args | default('') }}"
|
become: yes
|
||||||
|
command: "/root/{{ exec_item.name }} {{ exec_item.args | default('') }}"
|
||||||
environment: "{{ exec_item.environment | default('') }}"
|
environment: "{{ exec_item.environment | default('') }}"
|
||||||
always:
|
always:
|
||||||
- name: delete the file
|
- name: delete the file
|
||||||
|
become: yes
|
||||||
file:
|
file:
|
||||||
state: absent
|
state: absent
|
||||||
path: "~/{{ exec_item.name }}"
|
path: "/root/{{ exec_item.name }}"
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
LSPCI_CMD = 'lspci | grep Ethernet'
|
||||||
|
SYS_DEV_PATH = "/sys/bus/pci/devices/0000"
|
||||||
|
SRIOV_TOTAL_VFS_file = "/sriov_totalvfs"
|
||||||
|
SRIOV_NUM_VFS_file = "/sriov_numvfs"
|
||||||
|
SRIOV_SUPPORTED_NICS = ["82599ES", "X700 Series", "E800 Series"]
|
||||||
|
|
||||||
|
|
||||||
|
def configure_sriov_nic():
|
||||||
|
process = subprocess.run(LSPCI_CMD, shell=True, check=True,
|
||||||
|
stdout=subprocess.PIPE, universal_newlines=True)
|
||||||
|
proc = process.stdout.split('\n')
|
||||||
|
sriov_nics = find_sriov_supported_nics(proc)
|
||||||
|
for nic in sriov_nics:
|
||||||
|
NIC_BINARY_NUM = nic.split(' ')[0]
|
||||||
|
fp = open(SYS_DEV_PATH + ":" + NIC_BINARY_NUM + SRIOV_TOTAL_VFS_file)
|
||||||
|
if int(fp.read()) > 32:
|
||||||
|
fp.close()
|
||||||
|
with open(SYS_DEV_PATH+ ":" + NIC_BINARY_NUM + SRIOV_NUM_VFS_file, 'w') as file:
|
||||||
|
file.write('42')
|
||||||
|
|
||||||
|
def find_sriov_supported_nics(nics):
|
||||||
|
sriov_supported_nics = []
|
||||||
|
for nic in nics:
|
||||||
|
for sriov_nic in SRIOV_SUPPORTED_NICS:
|
||||||
|
if sriov_nic in nic:
|
||||||
|
sriov_supported_nics.append(nic)
|
||||||
|
return sriov_supported_nics
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
configure_sriov_nic()
|
Loading…
Reference in New Issue