fix read the representor phys_port_name

This patch fix the get_representor_port to read the
representor phys_port_name and not the phys_switch_id
to get the VF number.

Closes-Bug: #1702299

Change-Id: If4b8d2af0087497337897c7e93a065ab8ae9964b
This commit is contained in:
Moshe Levi
2017-07-04 17:31:29 +03:00
parent fff78cf0d2
commit d5b539433b
2 changed files with 18 additions and 1 deletions

View File

@@ -269,7 +269,7 @@ def get_representor_port(pf_ifname, vf_num):
continue
try:
with open(device_sw_id_file, 'r') as fd:
with open(device_port_name_file, 'r') as fd:
representor_num = fd.readline().rstrip()
except (OSError, IOError):
continue

View File

@@ -303,7 +303,24 @@ class LinuxNetTest(testtools.TestCase):
readline_mock = mock_open.return_value.readline
readline_mock.side_effect = (
['pf_sw_id', 'pf_sw_id', '1', 'pf_sw_id', '2'])
open_calls = (
[mock.call('/sys/class/net/pf_ifname/phys_switch_id', 'r'),
mock.call().readline(),
mock.call().__exit__(None, None, None),
mock.call('/sys/class/net/rep_vf_1/phys_switch_id', 'r'),
mock.call().readline(),
mock.call().__exit__(None, None, None),
mock.call('/sys/class/net/rep_vf_1/phys_port_name', 'r'),
mock.call().readline(),
mock.call().__exit__(None, None, None),
mock.call('/sys/class/net/rep_vf_2/phys_switch_id', 'r'),
mock.call().readline(),
mock.call().__exit__(None, None, None),
mock.call('/sys/class/net/rep_vf_2/phys_port_name', 'r'),
mock.call().readline(),
mock.call().__exit__(None, None, None)])
ifname = linux_net.get_representor_port('pf_ifname', '2')
mock_open.assert_has_calls(open_calls)
self.assertEqual('rep_vf_2', ifname)
@mock.patch('six.moves.builtins.open')