Skip to content

Commit 4761ca7

Browse files
mdboothEmilienM
authored andcommitted
network: Detect SR-IOV PFs and VFs
1 parent 51d9735 commit 4761ca7

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

playbooks/roles/network_info/tasks/main.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,59 @@
3434
content: "{{ network_info | to_nice_json }}"
3535
mode: 0755
3636
when: networkinfo_file.failed
37+
38+
- name: Find network devices with a device link
39+
find:
40+
paths: /sys/class/net
41+
patterns:
42+
- device
43+
file_type: link
44+
follow: true
45+
depth: 2
46+
recurse: true
47+
use_regex: false
48+
register: device_links
49+
50+
- name: Extract paths from device_links
51+
set_fact:
52+
device_links: "{{ device_links.files | map(attribute='path') | list }}"
53+
54+
- name: Extract device names from device_links
55+
set_fact:
56+
network_devices: "{{ network_devices + [ item | dirname | basename ] }}"
57+
loop: "{{ device_links }}"
58+
vars:
59+
network_devices: []
60+
61+
- name: Initialise SR-IOV PFs to an empty list
62+
set_fact:
63+
sriov_pfs: []
64+
65+
- name: Find SR-IOV PFs
66+
find:
67+
paths: "{{ device_links }}"
68+
patterns:
69+
- sriov_totalvfs
70+
register: sriov_totalvfs
71+
72+
- name: Extract device names for SR-IOV PFs
73+
set_fact:
74+
sriov_pfs: "{{ sriov_pfs + [ item | dirname | dirname | basename ] }}"
75+
loop: "{{ sriov_totalvfs.files | map(attribute='path') | list }}"
76+
77+
- name: Initialise SR-IOV VFs to an empty list
78+
set_fact:
79+
sriov_vfs: []
80+
81+
- name: Find SR-IOV VFs
82+
find:
83+
paths: "{{ device_links }}"
84+
patterns:
85+
- physfn
86+
file_type: link
87+
register: sriov_physfndir
88+
89+
- name: Extract device names for SR-IOV VFs
90+
set_fact:
91+
sriov_vfs: "{{ sriov_vfs + [ item | dirname | dirname | basename ] }}"
92+
loop: "{{ sriov_physfndir.files | map(attribute='path') | list }}"

0 commit comments

Comments
 (0)