You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 27, 2018. It is now read-only.
joshreich edited this page Dec 5, 2014
·
6 revisions
Changes to the network topology are one of the most fundamental sources of dynamism. Consequently, all dynamic policies have a set_network method which is automatically called by the runtime every time the network changes. By overriding this method, dynamic policies can access the updated network and its associated topology. Below is a simplified version of Pyretic's flood policy that recalculates the minimum spanning tree each time set_network is called and updates its internal policy to flood on that minimum spanning tree.
class flood(DynamicPolicy):
"""
Policy that floods packets on a minimum spanning tree, recalculated
every time the network is updated (set_network).
"""
def __init__(self):
self.mst = None
super(flood,self).__init__()
def set_network(self, network):
updated_mst = Topology.minimum_spanning_tree(network.topology)
self.policy = parallel([
match(switch=switch) >>
parallel(map(xfwd,ports))
for switch,ports
in self.mst.switch_with_port_ids_list()])
The following videos provide additional examples and details as to how the Pyretic runtime implements this feature: