-
Notifications
You must be signed in to change notification settings - Fork 71
net, libs: Refactor modules and add new lib helper #5072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f44f326
net: Move apimachinery and nncp modules to libs
azhivovk 8b90886
net, tests: Add vlan iterator and root fixture
azhivovk 9ac634e
net, tests: Move shared bridge_nncp and NAD fixtures
azhivovk 4a6efae
net: Move update_nad_references to libs/net/vmspec
azhivovk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
File renamed without changes.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Empty file.
Empty file.
This file contains hidden or 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,10 @@ | ||
| from collections.abc import Iterator | ||
|
|
||
| import pytest | ||
|
|
||
| from libs.net.cluster import cluster_vlans | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def cluster_vlan_ids() -> Iterator[int]: | ||
|
azhivovk marked this conversation as resolved.
|
||
| return iter(cluster_vlans()) | ||
This file contains hidden or 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,76 @@ | ||
| from collections.abc import Generator, Iterator | ||
|
azhivovk marked this conversation as resolved.
|
||
|
|
||
| import pytest | ||
| from kubernetes.dynamic import DynamicClient | ||
| from ocp_resources.namespace import Namespace | ||
|
|
||
| from libs.net import nodenetworkconfigurationpolicy as libnncp | ||
| from libs.net.netattachdef import CNIPluginBridgeConfig, NetConfig, NetworkAttachmentDefinition | ||
| from utilities.constants.cluster import WORKER_NODE_LABEL_KEY | ||
| from utilities.constants.networking import LINUX_BRIDGE | ||
|
|
||
|
|
||
| @pytest.fixture(scope="package") | ||
| def bridge_nncp( | ||
| nmstate_dependent_placeholder: None, | ||
| admin_client: DynamicClient, | ||
| hosts_common_available_ports: list[str], | ||
| ) -> Generator[libnncp.NodeNetworkConfigurationPolicy]: | ||
| with libnncp.NodeNetworkConfigurationPolicy( | ||
| client=admin_client, | ||
| name="l2-bridge-test-nncp", | ||
| desired_state=libnncp.DesiredState( | ||
| interfaces=[ | ||
| libnncp.Interface( | ||
| name="br1-test", | ||
| type=LINUX_BRIDGE, | ||
| state=libnncp.Resource.Interface.State.UP, | ||
| bridge=libnncp.Bridge( | ||
| port=[libnncp.Port(name=hosts_common_available_ports[-1])], | ||
| options=libnncp.BridgeOptions(libnncp.STP(enabled=False)), | ||
| ), | ||
| ) | ||
| ] | ||
| ), | ||
| node_selector={WORKER_NODE_LABEL_KEY: ""}, | ||
| ) as nncp_br: | ||
| nncp_br.wait_for_status_success() | ||
| yield nncp_br | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def bridge_nad_a( | ||
| admin_client: DynamicClient, | ||
| namespace: Namespace, | ||
| bridge_nncp: libnncp.NodeNetworkConfigurationPolicy, | ||
| cluster_vlan_ids: Iterator[int], | ||
| ) -> Generator[NetworkAttachmentDefinition]: | ||
| bridge = bridge_nncp.desired_state_spec.interfaces[0].name # type: ignore | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| with NetworkAttachmentDefinition( | ||
| name="nad-vlan-a", | ||
| namespace=namespace.name, | ||
| config=NetConfig( | ||
| name="nad-vlan-a", plugins=[CNIPluginBridgeConfig(bridge=bridge, vlan=next(cluster_vlan_ids))] | ||
| ), | ||
| client=admin_client, | ||
| ) as nad: | ||
| yield nad | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def bridge_nad_b( | ||
| admin_client: DynamicClient, | ||
| namespace: Namespace, | ||
| bridge_nncp: libnncp.NodeNetworkConfigurationPolicy, | ||
| cluster_vlan_ids: Iterator[int], | ||
| ) -> Generator[NetworkAttachmentDefinition]: | ||
| bridge = bridge_nncp.desired_state_spec.interfaces[0].name # type: ignore[union-attr, index] | ||
| with NetworkAttachmentDefinition( | ||
| name="nad-vlan-b", | ||
| namespace=namespace.name, | ||
| config=NetConfig( | ||
| name="nad-vlan-b", plugins=[CNIPluginBridgeConfig(bridge=bridge, vlan=next(cluster_vlan_ids))] | ||
| ), | ||
| client=admin_client, | ||
| ) as nad: | ||
| yield nad | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.