Skip to content
This repository has been archived by the owner on Jun 27, 2018. It is now read-only.

Commit

Permalink
add rule_entry class that simplifies rule checking for countbuckets
Browse files Browse the repository at this point in the history
  • Loading branch information
ngsrinivas committed Mar 5, 2016
1 parent 86fef70 commit 6f40d17
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions pyretic/core/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,13 @@ def __repr__(self):
',priority=' + repr(self.priority) +
',version=' + repr(self.version) + ')')

class rule_entry(match_entry):
def __init__(self, match, priority, version):
super(MatchingAggregateBucket.rule_entry, self).__init__(
match, priority, version)
self.match = util.frozendict(
{'switch':match['switch']} if 'switch' in match else {})

class match_status(object):
def __init__(self,to_be_deleted=False,existing_rule=False):
self.to_be_deleted = to_be_deleted
Expand Down Expand Up @@ -1074,8 +1081,12 @@ def handle_flow_removed(self, match, priority, version, flow_stat):
with self.in_update_cv:
while self.in_update:
self.in_update_cv.wait()
k = self.match_entry(self.str_convert_match(match),
priority, version)
''' To restore using matches, uncomment the following lines.
# k = self.match_entry(self.str_convert_match(match),
# priority, version)
'''
k = self.rule_entry(self.str_convert_match(match),
priority, version)
if k in self.matches:
self.log.debug("Deleted flow exists in the bucket's matches")
status = self.matches[k]
Expand Down Expand Up @@ -1203,9 +1214,19 @@ def stat_in_bucket(flow_stat, s):
bucket.matches."""
f = copy.copy(flow_stat['match'])
f['switch'] = s
fme = self.match_entry(self.str_convert_match(f),
flow_stat['priority'],
flow_stat['cookie'])
''' To restore using matches, uncomment the following lines.
# fme = self.match_entry(self.str_convert_match(f),
# flow_stat['priority'],
# flow_stat['cookie'])
Note that the change from match_entry to rule_entry implicitly
denotes the assumption about the runtime that rules are uniquely
identified by their cookie and priority, which denote (1) priority
in a given table, (2) the table itself, and (3) the version number
of the entire policy.
'''
fme = self.rule_entry(self.str_convert_match(f),
flow_stat['priority'],
flow_stat['cookie'])
if fme in self.matches.keys():
return fme
return None
Expand Down

0 comments on commit 6f40d17

Please sign in to comment.