コード例 #1
0
ファイル: topo_test.py プロジェクト: GreggyStills/pynetdraw
def loadfile(testfile):
    time_start = time.clock()
    with open (testfile, "r") as myfile:
        data = myfile.readlines()
    gr = isis_db_to_digraph(data)
    print "Parser execution time:", time.clock() - time_start, "seconds"
    return gr
コード例 #2
0
ファイル: draw_isis.py プロジェクト: GreggyStills/pynetdraw
def draw_isis(job, host, conn):
    """"Use Exscript to login to a Cisco IOS router, get the IS-IS database,
    and parse+analyze+draw the IS-IS topology."""
    # host.name is provided by Exscript, returns name of current host
    region = router_region[host.name]
    conn.send("enable\r")
    conn.app_authorize()
    conn.execute('term len 0')
    conn.execute('show isis database detail')
    isis_db = conn.response
    # Got the database, now parse it into a DiGraph
    topo = isis_db_to_digraph(isis_db, region)
    # Got topology DiGraph, now analyze it for potential SPOF impacts
    impacts = spofs(topo)
    # Got topology & SPOF impacts, now save the diagram (SVG) in the current
    # working directory, and try to upload the topology XML data (SVG+GraphML)
    # to MongoDB server
    topo_entry = draw(topo, impacts, save_svg=True, return_svg=True, return_graphml=True)
    topo_entry['region'] = region
    topo_entry['timestamp'] = topo.graph['timestamp']
    mongo_save(topo_entry)
    # use conn.send to 'exit' because conn.execute waits for a normal
    # prompt that will never come, and cause a script timeout error.
    conn.send('exit')