Skip to content

Commit

Permalink
Further refining code by deleting unused original implementatation code.
Browse files Browse the repository at this point in the history
Signed-off-by: Tanya <tatyana@il.ibm.com>
  • Loading branch information
tanyaveksler committed May 7, 2024
1 parent cc432e3 commit e9b1e7f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
6 changes: 2 additions & 4 deletions nca/Resources/PolicyResources/CalicoNetworkPolicy.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,15 @@ def __init__(self, src_peers, dst_peers, action, props):
self.props_copy = ConnectivityProperties()

def __eq__(self, other):
return self.src_peers == other.src_peers and self.dst_peers == other.dst_peers and \
self.props == other.props and self.action == other.action
return self.props == other.props and self.action == other.action

def contained_in(self, other):
"""
:param CalicoPolicyRule other: Another rule
:return: Whether all connections specified by 'self' are also specified by 'other' (regardless of action)
:rtype: bool
"""
return self.src_peers.issubset(other.src_peers) and self.dst_peers.issubset(other.dst_peers) and \
self.props.contained_in(other.props)
return self.props.contained_in(other.props)

@staticmethod
def action_str_to_action_type(action_str):
Expand Down
4 changes: 2 additions & 2 deletions nca/Resources/PolicyResources/GatewayPolicy.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ def __init__(self, peer_set, props):
self.props_copy = ConnectivityProperties()

def __eq__(self, other):
return self.peer_set == other.peer_set and self.props == other.props
return self.props == other.props

def contained_in(self, other):
"""
: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.props.contained_in(other.props)
return self.props.contained_in(other.props)


class GatewayPolicy(NetworkPolicy):
Expand Down
4 changes: 2 additions & 2 deletions nca/Resources/PolicyResources/IstioNetworkPolicy.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ def __init__(self, peer_set, props):
self.props_copy = ConnectivityProperties()

def __eq__(self, other):
return self.peer_set == other.peer_set and self.props == other.props
return self.props == other.props

def contained_in(self, other):
"""
:param IstioPolicyRule 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.props.contained_in(other.props)
return self.props.contained_in(other.props)


class IstioNetworkPolicy(NetworkPolicy):
Expand Down
4 changes: 2 additions & 2 deletions nca/Resources/PolicyResources/K8sNetworkPolicy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ def __init__(self, peer_set, props):
self.props_copy = ConnectivityProperties()

def __eq__(self, other):
return self.peer_set == other.peer_set and self.props == other.props
return self.props == other.props

def contained_in(self, other):
"""
:param K8sPolicyRule 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.props.contained_in(other.props)
return self.props.contained_in(other.props)


class K8sNetworkPolicy(NetworkPolicy):
Expand Down

0 comments on commit e9b1e7f

Please sign in to comment.