Skip to content

Commit 8aec5ec

Browse files
authored
feat: add RouteAdvertisements and FRRConfiguration classes (#2490)
1 parent acccb5e commit 8aec5ec

File tree

3 files changed

+136
-0
lines changed

3 files changed

+136
-0
lines changed

ocp_resources/frr_configuration.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md
2+
3+
4+
from typing import Any
5+
from ocp_resources.resource import NamespacedResource
6+
7+
8+
class FRRConfiguration(NamespacedResource):
9+
"""
10+
FRRConfiguration is a piece of FRR configuration.
11+
"""
12+
13+
api_group: str = NamespacedResource.ApiGroup.FRRK8S_METALLB_IO
14+
15+
def __init__(
16+
self,
17+
bgp: dict[str, Any] | None = None,
18+
node_selector: dict[str, Any] | None = None,
19+
raw: dict[str, Any] | None = None,
20+
**kwargs: Any,
21+
) -> None:
22+
r"""
23+
Args:
24+
bgp (dict[str, Any]): BGP is the configuration related to the BGP protocol.
25+
26+
node_selector (dict[str, Any]): NodeSelector limits the nodes that will attempt to apply this config.
27+
When specified, the configuration will be considered only on nodes
28+
whose labels match the specified selectors. When it is not
29+
specified all nodes will attempt to apply this config.
30+
31+
raw (dict[str, Any]): Raw is a snippet of raw frr configuration that gets appended to the
32+
one rendered translating the type safe API.
33+
34+
"""
35+
super().__init__(**kwargs)
36+
37+
self.bgp = bgp
38+
self.node_selector = node_selector
39+
self.raw = raw
40+
41+
def to_dict(self) -> None:
42+
super().to_dict()
43+
44+
if not self.kind_dict and not self.yaml_file:
45+
self.res["spec"] = {}
46+
_spec = self.res["spec"]
47+
48+
if self.bgp is not None:
49+
_spec["bgp"] = self.bgp
50+
51+
if self.node_selector is not None:
52+
_spec["nodeSelector"] = self.node_selector
53+
54+
if self.raw is not None:
55+
_spec["raw"] = self.raw
56+
57+
# End of generated code

ocp_resources/resource.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ class ApiGroup:
491491
EXPORT_KUBEVIRT_IO: str = "export.kubevirt.io"
492492
FENCE_AGENTS_REMEDIATION_MEDIK8S_IO: str = "fence-agents-remediation.medik8s.io"
493493
FORKLIFT_KONVEYOR_IO: str = "forklift.konveyor.io"
494+
FRRK8S_METALLB_IO = "frrk8s.metallb.io"
494495
HCO_KUBEVIRT_IO: str = "hco.kubevirt.io"
495496
HELM_MARIADB_MMONTES_IO: str = "helm.mariadb.mmontes.io"
496497
HIVE_OPENSHIFT_IO: str = "hive.openshift.io"
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md
2+
3+
4+
from typing import Any
5+
from ocp_resources.resource import Resource
6+
from ocp_resources.exceptions import MissingRequiredArgumentError
7+
8+
9+
class RouteAdvertisements(Resource):
10+
"""
11+
RouteAdvertisements is the Schema for the routeadvertisements API
12+
"""
13+
14+
api_group: str = Resource.ApiGroup.K8S_OVN_ORG
15+
16+
def __init__(
17+
self,
18+
advertisements: list[Any] | None = None,
19+
frr_configuration_selector: dict[str, Any] | None = None,
20+
network_selectors: list[Any] | None = None,
21+
node_selector: dict[str, Any] | None = None,
22+
target_vrf: str | None = None,
23+
**kwargs: Any,
24+
) -> None:
25+
r"""
26+
Args:
27+
advertisements (list[Any]): advertisements determines what is advertised.
28+
29+
frr_configuration_selector (dict[str, Any]): frrConfigurationSelector determines which FRRConfigurations will the
30+
OVN-Kubernetes driven FRRConfigurations be based on. This field
31+
follows standard label selector semantics.
32+
33+
network_selectors (list[Any]): networkSelectors determines which network routes should be advertised.
34+
Only ClusterUserDefinedNetworks and the default network can be
35+
selected.
36+
37+
node_selector (dict[str, Any]): nodeSelector limits the advertisements to selected nodes. This field
38+
follows standard label selector semantics.
39+
40+
target_vrf (str): targetVRF determines which VRF the routes should be advertised in.
41+
42+
"""
43+
super().__init__(**kwargs)
44+
45+
self.advertisements = advertisements
46+
self.frr_configuration_selector = frr_configuration_selector
47+
self.network_selectors = network_selectors
48+
self.node_selector = node_selector
49+
self.target_vrf = target_vrf
50+
51+
def to_dict(self) -> None:
52+
super().to_dict()
53+
54+
if not self.kind_dict and not self.yaml_file:
55+
if self.advertisements is None:
56+
raise MissingRequiredArgumentError(argument="self.advertisements")
57+
58+
if self.frr_configuration_selector is None:
59+
raise MissingRequiredArgumentError(argument="self.frr_configuration_selector")
60+
61+
if self.network_selectors is None:
62+
raise MissingRequiredArgumentError(argument="self.network_selectors")
63+
64+
if self.node_selector is None:
65+
raise MissingRequiredArgumentError(argument="self.node_selector")
66+
67+
self.res["spec"] = {}
68+
_spec = self.res["spec"]
69+
70+
_spec["advertisements"] = self.advertisements
71+
_spec["frrConfigurationSelector"] = self.frr_configuration_selector
72+
_spec["networkSelectors"] = self.network_selectors
73+
_spec["nodeSelector"] = self.node_selector
74+
75+
if self.target_vrf is not None:
76+
_spec["targetVRF"] = self.target_vrf
77+
78+
# End of generated code

0 commit comments

Comments
 (0)