#!/bin/python

from Parser import Parser
from Grapher import Grapher

from networkx.readwrite import json_graph

import networkx as nx
import json
import sys

if __name__ == "__main__":
    p = Parser( sys.argv[1] )

    g = Grapher ( p.xml_to_json() )
    graph = g.json_to_graph()

    for n in graph:
        graph.node[n]['name'] = n

    d = json_graph.node_link_data( graph )
    json.dump( d, open( 'graph.json', 'w' ) )
import networkx as nx

if __name__ == "__main__":
    # start parser with command line arg
    p = Parser(sys.argv[1])

    # this is the topology in json
    net = p.xml_to_json()

    # list of emulated flows
    emuflows = p.emuflows()

    # translate to networkx
    graph = Grapher(net)

    g = graph.json_to_graph()

    d = Downscaler(emuflows, g)

    pipes = d.get_pipes()

    for p in pipes:
        print p
    print '\n'

    st = SymbioTopo(net, pipes)
    st.getNodes()

    for e in emuflows:
        print e
#!/bin/python

import sys
from Parser import Parser
from Grapher import Grapher
from Flows import Flows

import networkx as nx

if __name__ == "__main__":
    p = Parser(sys.argv[1])
    net = p.xml_to_json()

    g = Grapher(net)
    graph = g.json_to_graph()

    print 'Enter a flow between two hosts (e.g., h1, h2)'
    i = 1
    for n in graph.nodes(data=True):
        if n[1].get('type') == 'host':
            print str(i) + '. ' + n[0]
            i = i + 1

    flows = []
    flow = 'default'
    while flow != '':
        flow = raw_input('Flow: ')
        if flow != '':
            flows.append(flow.split(','))
    # perhaps we should sanitize the list here?
import networkx as nx

if __name__ == "__main__":
    # start parser with command line arg
    p = Parser( sys.argv[1] )

    # this is the topology in json
    net = p.xml_to_json()

    # list of emulated flows
    emuflows = p.emuflows()

    # translate to networkx 
    graph = Grapher( net )
    
    g = graph.json_to_graph()
 
    d = Downscaler( emuflows, g ) 

    pipes = d.get_pipes()

    for p in pipes:
        print p
    print '\n'

    st = SymbioTopo( net, pipes )
    st.getNodes()

    for e in emuflows:
        print e