Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
James Denton
committed
Aug 21, 2019
1 parent
fb9a2af
commit 37e3082
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
roles/neutron-sriov/templates/pf9-sriov-vf-manager.service.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[Unit] | ||
Description=Platform9 SR-IOV Virtual Function Manager | ||
Wants=network-online.target | ||
After=network-online.target | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=/opt/pf9/pf9-virtual-functions.sh start | ||
ExecStop=/opt/pf9/pf9-virtual-functions.sh stop | ||
ExecReload=/opt/pf9/pf9-virtual-functions.sh reload | ||
StandardOutput=journal | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
# Copyright 2019 Platform9 Systems Inc. | ||
# All Rights Reserved. | ||
|
||
## | ||
# This script implements SR-IOV virtual functions based on variables defined | ||
# within Platform9 Express. | ||
# | ||
# DO NOT EDIT THIS FILE MANUALLY! | ||
## | ||
|
||
# VF Array | ||
declare -A vfs | ||
|
||
{% for vf in sriov_numvfs %} | ||
vfs[{{ vf.split(':')[0] }}]={{ vf.split(':')[1] }} | ||
{% endfor %} | ||
|
||
function get_vf_count { | ||
vf_count=$(</sys/class/net/$1/device/sriov_numvfs) | ||
} | ||
|
||
function unset_vf { | ||
echo 0 > /sys/class/net/$1/device/sriov_numvfs | ||
} | ||
|
||
function set_vf { | ||
echo $2 > /sys/class/net/$1/device/sriov_numvfs | ||
} | ||
|
||
function start { | ||
for vf in "${!vfs[@]}" | ||
do | ||
echo "Enabling ${vfs[$vf]} virtual functions on $vf." | ||
set_vf $vf ${vfs[$vf]} | ||
done | ||
} | ||
|
||
function stop { | ||
for vf in "${!vfs[@]}" | ||
do | ||
echo "Removing virtual functions from $vf." | ||
unset_vf $vf | ||
done | ||
} | ||
|
||
function reload { | ||
for vf in "${!vfs[@]}" | ||
do | ||
get_vf_count $vf | ||
if [ "$vf_count" -ne "${vfs[$vf]}" ]; then | ||
echo "Virtual function count has changed. Resetting virtual functions on $vf. Affected VMs must be power cycled to restore connectivity!" | ||
unset_vf $vf | ||
set_vf $vf ${vfs[$vf]} | ||
else | ||
echo "Virtual function count on $vf has not changed. Ignoring service reload." | ||
fi | ||
done | ||
} | ||
|
||
"$@" |