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

Commit 4238132

Browse files
author
Joshua Reich
committed
updated topology_printer example
1 parent 6651643 commit 4238132

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

pyretic/examples/topology_printer.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,25 @@
1212
class topology_printer(DynamicPolicy):
1313

1414
def __init__(self):
15-
self.topology = None
15+
self.last_topology = None
1616
self.lock = Lock()
1717
super(topology_printer,self).__init__()
1818

1919
def set_network(self, network):
2020
with self.lock:
21-
if self.topology and (self.topology == network.topology):
22-
pass
21+
print '------New Topology Information----------'
22+
print '---Switch ID list'
23+
print network.switches()
24+
print '---Switch ID paired with port ID list'
25+
print network.switches(with_ports=True)
26+
print '---Convert network topology object to string'
27+
print network.topology
28+
print '---Has changed: ',
29+
if self.last_topology:
30+
print self.last_topology != network.topology
2331
else:
24-
print self.topology
25-
print network.topology
26-
self.topology = network.topology
27-
print self.topology
28-
32+
print True
33+
self.last_topology = network.topology
2934

3035
def main ():
3136
return topology_printer()

0 commit comments

Comments
 (0)