Home | Trees | Indices | Help |
|
---|
|
The Topology class represents the network topology as seen by a protocol in an element.It provides methods to obtain the topology graph and to register listener for receiving topology change events. A topology contains a list of edges. Each edge denotes the connectivity between two node connectors which in turn are hosted in network nodes. For protocols such as CDP and EIGRP, the topology will contain only one-hop neighbors. For OSPF or any other link state protocol it is possible to obtain a complete topology pertaining to an area. A Topology object will provide only the topology graph and report topology changes as seen by an element. In the case where the application chooses to obtain incremental topology by connecting to each discovered node, then a new Topology object should be instantiated using the new node. Example: #Get NetworkElement and connect to it network_element = element.NetworkElement.NetworkElement("127.0.0.1","pythonapp") handle = network_element.connect("cisco", "cisco") # create a Topology object based on Topology Type # The Topology object will keep a Graph object and will also keep the graph # updated based on the events received # The latest graph can be obtained by using the graph property topology = TopologyClass(network_element, Topology.TopologyType.CDP) # Get the Graph object which reflect the current snapshot. graph = topology.get_graph() # A topology Graph contains a list of Edge objects. We can traverse the # Graph by visiting each Edge object in the list. for (edge in graph.get_edge_list(Edge.EdgeType.UNDIRECTED)): edge_count = 1 print "Edge #" + str(edge_count) edge_count += 1 # Every Edge object has a head NodeConnector and tail NodeConnector # on its two ends. edge_connector = edge.head_node_connector tail_connector = edge.tail_node_connector # Each NodeConnector in turn is housed in a topology Node. head_node = head_connector.node tail_node = tail_connector.node # print information of connectors and nodes print "Head Connector name " + head_connector.name + ",type = " + str(head_connector.type) print "Head Node :" + head_node.name + ",type = " + str(head_node.type) # Print information of connectors and nodes for addr in headnode.address_list: print " address: " + addr print "Tail Connector name :" + tail_connector.name + ",type = " + str(tail_connector.type) print "Tail Node: " + tail_node.name + "type = " + str(tail_node.type) for addr in tail_node.address_list: print "address : " + addr class MyTopologyListener(TopologyListener): def handle_event(self, event, clientData): print "-------------" print Topology Event print "-------------" listener = MyTopologyListener() event_type = [] event_type.append(TopologyEvent.TopologyEventType.EDGES_ADD) event_type.append(TopologyEvent.TopologyEventType.EDGES_DELETE) filter = TopologyFilter(event_type) event_handle = topology.add_topology_listener(listener, filter, None)
Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
Inherited from |
Class Variables | |
TopologyType = enum('CDP')
|
|
network_element = property(_get_network_element, None, _doc)
|
|
type = property(_get_type, None)
|
Properties | |
Inherited from |
Method Details |
Construct a Topology object as seen by a protocol in an element.
|
Get the topology graph that represents the current snapshot of the topology. This method assumes that the network element is connected. If it is not,OnepConnectionException will be thrown.
|
Adds a topology event listener to the Topology object.
|
Removes the topology event listener. This method will remove the listener associated with the specified eventHandle and also remove the corresponding registered event on the NetworkElement
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Mon Aug 18 09:17:34 2014 | http://epydoc.sourceforge.net |