The default max/min tx rates shall not halt deployment

The default configuration of max_tx_rate and min_tx_rate is 0.
Some of the SR-IOV driver implementation throws up the error for
the default values and the errors shall be safely handled instead
of raising an exception.

Change-Id: I0e6ee35e327d36ddc1b792de1ee48bad609bc3ad
(cherry picked from commit 44eab2297f)
This commit is contained in:
Karthik S 2021-12-01 14:55:35 +00:00
parent 8b87e56b92
commit e15af3bbb5
1 changed files with 16 additions and 2 deletions

View File

@ -555,6 +555,14 @@ def get_vendor_id(ifname):
return
def run_ip_config_cmd_safe(raise_error, *cmd, **kwargs):
try:
run_ip_config_cmd(*cmd)
except processutils.ProcessExecutionError:
if raise_error:
raise
def get_pf_pci(pf_name):
pf_pci_path = _get_dev_path(pf_name, "uevent")
pf_info = get_file_data(pf_pci_path)
@ -602,12 +610,14 @@ def if_up_interface(device):
def configure_sriov_vf():
sriov_map = _get_sriov_map()
for item in sriov_map:
raise_error = True
if item['device_type'] == 'vf':
pf_name = item['device']['name']
vfid = item['device']['vfid']
base_cmd = ('ip', 'link', 'set', 'dev', pf_name, 'vf', str(vfid))
logger.info(f"Configuring settings for PF: {pf_name} VF: {vfid} "
f"VF name: {item['name']}")
raise_error = True
if 'macaddr' in item:
cmd = base_cmd + ('mac', item['macaddr'])
run_ip_config_cmd(*cmd)
@ -618,10 +628,14 @@ def configure_sriov_vf():
run_ip_config_cmd(*vlan_cmd)
if 'max_tx_rate' in item:
cmd = base_cmd + ('max_tx_rate', str(item['max_tx_rate']))
run_ip_config_cmd(*cmd)
if item['max_tx_rate'] == 0:
raise_error = False
run_ip_config_cmd_safe(raise_error, *cmd)
if 'min_tx_rate' in item:
cmd = base_cmd + ('min_tx_rate', str(item['min_tx_rate']))
run_ip_config_cmd(*cmd)
if item['min_tx_rate'] == 0:
raise_error = False
run_ip_config_cmd_safe(raise_error, *cmd)
if 'spoofcheck' in item:
cmd = base_cmd + ('spoofchk', item['spoofcheck'])
run_ip_config_cmd(*cmd)