Skip to content

Commit

Permalink
cli/sriov: remove unused code
Browse files Browse the repository at this point in the history
We are parsing all the configuration unnecessarily here. np_state is
being overridden by the State instance from the config manager.

Fix a related unit test. The configuration is expected to fail but now
it's failing in a different place and raising a different exception.
  • Loading branch information
daniloegea committed Jan 18, 2024
1 parent 517d0f8 commit dcc369b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
6 changes: 0 additions & 6 deletions netplan_cli/cli/sriov.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,6 @@ def apply_sriov_config(config_manager, rootdir='/'):
Go through all interfaces, identify which ones are SR-IOV VFs, create
them and perform all other necessary setup.
"""
parser = netplan.Parser()
parser.load_yaml_hierarchy(rootdir)

np_state = netplan.State()
np_state.import_parser_results(parser)

config_manager.parse()
interfaces = netifaces.interfaces()
np_state = config_manager.np_state
Expand Down
3 changes: 1 addition & 2 deletions tests/test_sriov.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from collections import defaultdict
from unittest.mock import patch, mock_open, call

import netplan
import netplan_cli.cli.sriov as sriov

from netplan_cli.configmanager import ConfigManager, ConfigurationError
Expand Down Expand Up @@ -578,7 +577,7 @@ def test_apply_sriov_config_invalid_vlan(self, gim, gidn, apply_vlan, quirks,
gim.return_value = '00:01:02:03:04:05'

# call method under test
with self.assertRaises(netplan.NetplanValidationException) as e:
with self.assertRaises(ConfigurationError) as e:
sriov.apply_sriov_config(self.configmanager, rootdir=self.workdir.name)

self.assertIn('vf1.15: missing \'id\' property', str(e.exception))
Expand Down

0 comments on commit dcc369b

Please sign in to comment.