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

Accessing Topology

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 simple example that stores the most recent topology.

class topo_reader(DynamicPolicy):
    """
    Policy that stores the topology
    """
    def __init__(self):
        self.network = None
        super(topo_reader,self).__init__()

    def set_network(self, network):
        self.network = network

    def read_topology(self):
        return self.network.topology

    def __repr__(self):
        return "topo_reader"

The following videos provide additional examples and details as to how the Pyretic runtime implements this feature:

Clone this wiki locally