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

Commit f00f2e2

Browse files
author
Joshua Reich
committed
compilation checks
1 parent 9d8402d commit f00f2e2

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

pyretic/core/runtime.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,25 @@ def concretize_action(a):
558558
crs = filter(lambda cr: not cr is None,crs)
559559
return Classifier(crs)
560560

561+
def check_OF_rules(classifier):
562+
def check_OF_rule_has_outport(r):
563+
for a in r.actions:
564+
if not 'outport' in a:
565+
raise TypeError('Invalid rule: concrete actions must have an outport',str(r))
566+
def check_OF_rule_has_compilable_action_list(r):
567+
if len(r.actions)<2:
568+
pass
569+
else:
570+
moded_fields = set(r.actions[0].keys())
571+
for a in r.actions:
572+
fields = set(a.keys())
573+
if fields - moded_fields:
574+
raise TypeError('Non-compilable rule',str(r))
575+
for r in classifier.rules:
576+
check_OF_rule_has_outport(r)
577+
check_OF_rule_has_compilable_action_list(r)
578+
return Classifier(classifier.rules)
579+
561580
def OF_inportize(classifier):
562581
"""
563582
Specialize classifier to ensure that packets to be forwarded
@@ -642,6 +661,7 @@ def nuclear_install(classifier):
642661
switches = switch_to_attrs.keys()
643662
classifier = switchify(classifier,switches)
644663
classifier = concretize(classifier)
664+
classifier = check_OF_rules(classifier)
645665
classifier = OF_inportize(classifier)
646666
new_rules = prioritize(classifier)
647667

0 commit comments

Comments
 (0)