From 1ac861d93996ba40ea5a1090a83e29ef3ec79d7b Mon Sep 17 00:00:00 2001 From: Tanya Date: Tue, 7 Nov 2023 14:40:37 +0200 Subject: [PATCH] Renamed IstioGatewayPolicy to GatewayPolicy. Signed-off-by: Tanya --- nca/NetworkConfig/NetworkConfigQuery.py | 4 ++-- nca/Parsers/GenericIngressLikeYamlParser.py | 4 ++-- nca/Parsers/IngressPolicyYamlParser.py | 4 ++-- nca/Parsers/IstioTrafficResourcesYamlParser.py | 4 ++-- .../{IstioGatewayPolicy.py => GatewayPolicy.py} | 12 ++++++------ 5 files changed, 14 insertions(+), 14 deletions(-) rename nca/Resources/{IstioGatewayPolicy.py => GatewayPolicy.py} (96%) diff --git a/nca/NetworkConfig/NetworkConfigQuery.py b/nca/NetworkConfig/NetworkConfigQuery.py index 78b427a1..bf1967d7 100644 --- a/nca/NetworkConfig/NetworkConfigQuery.py +++ b/nca/NetworkConfig/NetworkConfigQuery.py @@ -19,7 +19,7 @@ from nca.FWRules.ClusterInfo import ClusterInfo from nca.Resources.NetworkPolicy import PolicyConnectionsFilter from nca.Resources.CalicoNetworkPolicy import CalicoNetworkPolicy -from nca.Resources.IstioGatewayPolicy import IstioGatewayPolicy +from nca.Resources.GatewayPolicy import GatewayPolicy from nca.Utils.OutputConfiguration import OutputConfiguration from .QueryOutputHandler import QueryAnswer, DictOutputHandler, StringOutputHandler, \ PoliciesAndRulesExplanations, PodsListsExplanations, ConnectionsDiffExplanation, IntersectPodsExplanation, \ @@ -1282,7 +1282,7 @@ def clone_without_ingress(config): return config # no ingress policies in this config config_without_ingress = config.clone_without_policies(config.name) for policy in config.policies_container.policies.values(): - if not isinstance(policy, IstioGatewayPolicy): # ignoring ingress policies + if not isinstance(policy, GatewayPolicy): # ignoring ingress policies config_without_ingress.append_policy_to_config(policy) return config_without_ingress diff --git a/nca/Parsers/GenericIngressLikeYamlParser.py b/nca/Parsers/GenericIngressLikeYamlParser.py index 574bed4c..34a8ef72 100644 --- a/nca/Parsers/GenericIngressLikeYamlParser.py +++ b/nca/Parsers/GenericIngressLikeYamlParser.py @@ -11,7 +11,7 @@ from nca.CoreDS.ProtocolSet import ProtocolSet from nca.CoreDS.ConnectivityProperties import ConnectivityProperties from nca.CoreDS.ConnectionSet import ConnectionSet -from nca.Resources.IstioGatewayPolicy import IstioGatewayPolicyRule +from nca.Resources.GatewayPolicy import GatewayPolicyRule from .GenericYamlParser import GenericYamlParser @@ -81,7 +81,7 @@ def _make_allow_rules(conn_props, src_peers): new_props = ConnectivityProperties.make_conn_props(new_conn_cube) new_conns = ConnectionSet() new_conns.add_connections('TCP', new_props) - res.append(IstioGatewayPolicyRule(dst_peer_set, new_conns, rule_opt_props)) + res.append(GatewayPolicyRule(dst_peer_set, new_conns, rule_opt_props)) return res @staticmethod diff --git a/nca/Parsers/IngressPolicyYamlParser.py b/nca/Parsers/IngressPolicyYamlParser.py index 451c05be..dd1fb20e 100644 --- a/nca/Parsers/IngressPolicyYamlParser.py +++ b/nca/Parsers/IngressPolicyYamlParser.py @@ -10,7 +10,7 @@ from nca.CoreDS.PortSet import PortSet from nca.CoreDS.ConnectivityCube import ConnectivityCube from nca.CoreDS.ConnectivityProperties import ConnectivityProperties -from nca.Resources.IstioGatewayPolicy import IstioGatewayPolicy +from nca.Resources.GatewayPolicy import GatewayPolicy from nca.Resources.NetworkPolicy import NetworkPolicy from .GenericIngressLikeYamlParser import GenericIngressLikeYamlParser @@ -254,7 +254,7 @@ def parse_policy(self): return None # Not an Ingress object self.namespace = self.peer_container.get_namespace(policy_ns) - res_policy = IstioGatewayPolicy(policy_name + '/allow', self.namespace) + res_policy = GatewayPolicy(policy_name + '/allow', self.namespace) res_policy.policy_kind = NetworkPolicy.PolicyType.Ingress res_policy.affects_egress = True policy_spec = self.policy['spec'] diff --git a/nca/Parsers/IstioTrafficResourcesYamlParser.py b/nca/Parsers/IstioTrafficResourcesYamlParser.py index ddb2c561..357e5c1e 100644 --- a/nca/Parsers/IstioTrafficResourcesYamlParser.py +++ b/nca/Parsers/IstioTrafficResourcesYamlParser.py @@ -10,7 +10,7 @@ from nca.CoreDS.ConnectivityCube import ConnectivityCube from nca.CoreDS.ConnectivityProperties import ConnectivityProperties from nca.Resources.IstioTrafficResources import Gateway, VirtualService -from nca.Resources.IstioGatewayPolicy import IstioGatewayPolicy +from nca.Resources.GatewayPolicy import GatewayPolicy from nca.Resources.NetworkPolicy import NetworkPolicy from .GenericIngressLikeYamlParser import GenericIngressLikeYamlParser @@ -390,7 +390,7 @@ def create_istio_traffic_policies(self): peers_to_hosts[peers] = host_dfa for peer_set, host_dfa in peers_to_hosts.items(): - res_policy = IstioGatewayPolicy(vs.name + '/' + str(host_dfa) + '/allow', vs.namespace) + res_policy = GatewayPolicy(vs.name + '/' + str(host_dfa) + '/allow', vs.namespace) res_policy.policy_kind = NetworkPolicy.PolicyType.Ingress res_policy.affects_egress = True res_policy.selected_peers = peer_set diff --git a/nca/Resources/IstioGatewayPolicy.py b/nca/Resources/GatewayPolicy.py similarity index 96% rename from nca/Resources/IstioGatewayPolicy.py rename to nca/Resources/GatewayPolicy.py index 4cadf8ee..02e6f778 100644 --- a/nca/Resources/IstioGatewayPolicy.py +++ b/nca/Resources/GatewayPolicy.py @@ -9,7 +9,7 @@ from .NetworkPolicy import PolicyConnections, OptimizedPolicyConnections, NetworkPolicy -class IstioGatewayPolicyRule: +class GatewayPolicyRule: """ A class representing a single ingress rule in an Ingress object """ @@ -30,14 +30,14 @@ def __eq__(self, other): def contained_in(self, other): """ - :param IstioGatewayPolicyRule other: Another rule + :param GatewayPolicyRule other: Another rule :return: whether the self rule is contained in the other rule (self doesn't allow anything that other does not) :type: bool """ return self.peer_set.issubset(other.peer_set) and self.connections.contained_in(other.connections) -class IstioGatewayPolicy(NetworkPolicy): +class GatewayPolicy(NetworkPolicy): """ This class implements ingress controller logic for incoming http(s) requests The logic is kept similarly to NetworkPolicy, where the selected_peers are the ingress/egress controller peers, @@ -157,12 +157,12 @@ def has_empty_rules(self, _config_name=''): def clone_without_rule(self, rule_to_exclude, ingress_rule): """ Makes a copy of 'self' without a given policy rule - :param IstioGatewayPolicyRule rule_to_exclude: The one rule not to include in the copy + :param GatewayPolicyRule rule_to_exclude: The one rule not to include in the copy :param bool ingress_rule: Whether the rule is an ingress or egress rule :return: A copy of 'self' without the provided rule - :rtype: IstioGatewayPolicy + :rtype: GatewayPolicy """ - res = IstioGatewayPolicy(self.name, self.namespace) + res = GatewayPolicy(self.name, self.namespace) res.selected_peers = self.selected_peers res.affects_egress = self.affects_egress res.affects_ingress = self.affects_ingress