Beispiel #1
0
parser.add_argument('--topo', help="specify topo to use", default=('grid', ["5", "5", "100000000", "10", "200"]),
                    type=valid_topo)

parser.add_argument('--plot', dest="plot", action="store_true")
parser.add_argument('--disable-heuristic', dest="disable_heuristic", action="store_true")
parser.add_argument('--dest_folder', help="destination folder for restults", default=RESULTS_FOLDER)
parser.add_argument('--json', help='display json results in stdout', dest="json", action="store_true")
parser.add_argument('--base64', help='display json results in base64', dest="b64", action="store_true")

args = parser.parse_args()

if args.disable_embedding:
    rs, su = clean_and_create_experiment(args.topo, 0)

    su.write(RESULTS_FOLDER)
    plotsol_from_db(service_link_linewidth=5, net=True, substrate=su)
    subprocess.Popen(
        ["neato", os.path.join(RESULTS_FOLDER, "./substrate.dot"), "-Tsvg", "-o",
         os.path.join(args.dest_folder, "topo.svg")]).wait()
    shutil.copy(os.path.join(RESULTS_FOLDER, "./substrate.dot"), os.path.join(args.dest_folder, "substrate.dot"))


else:

    if args.auto is False and (args.vhg is None or args.vcdn is None):
        parser.error('please specify --vhg and --vcdn args if not automatic calculation')
    elif args.auto is True and (args.vhg is not None or args.vcdn is not None):
        parser.error("can't specify vhg count of vcdn count in --auto mode")

    rs, su = clean_and_create_experiment(args.topo, args.seed)
Beispiel #2
0
parser.add_argument("-s", '--serviceid', type=int)

args = parser.parse_args()

# if not args.net:
#     graphiz_exe="neato"
# else:
#     graphiz_exe="dot"

session = Session()
service = session.query(Service).order_by(Service.id.desc()).all()
if len(service)>0 :
    service = service[0]
    service_id = str(service.id)
# service.slas[0].substrate.write(path=str(args.serviceid))

dosvg = args.dosvg
plotsol_from_db(service_link_linewidth=args.service_link_linewidth, net=args.net, service=service)
if not dosvg:
    file = tempfile.mkstemp(".pdf")[1]
    subprocess.Popen(
        ["neato", os.path.join(RESULTS_FOLDER, service_id, "../substrate.dot"), "-Tpdf", "-o", file]).wait()
    if args.view:
        subprocess.Popen(["evince", file]).wait()
else:
    file = args.dest
    subprocess.Popen(
        ["neato", os.path.join(RESULTS_FOLDER, service_id, "../substrate.dot"), "-Tsvg", "-o", file]).wait()
    if args.view:
        subprocess.Popen(["eog", file]).wait()
Beispiel #3
0
args = parser.parse_args()

if args.disable_embedding:
    rs, su = clean_and_create_experiment(args.topo, 0)

    su.write(RESULTS_FOLDER)
    if args.json:
        topo = su.get_json()
        if args.b64:
            sys.stdout.write(base64.b64encode(json.dumps(topo)))
        else:
            sys.stdout.write(json.dumps(topo))
        sys.stdout.flush()
    if args.plot:
        plotsol_from_db(service_link_linewidth=5, net=True, substrate=su)
        subprocess.Popen([
            "neato",
            os.path.join(RESULTS_FOLDER, "./substrate.dot"), "-Tsvg", "-o",
            os.path.join(args.dest_folder, "topo.svg")
        ]).wait()
        source_path = os.path.normpath(
            os.path.join(RESULTS_FOLDER, "./substrate.dot"))
        dest_path = os.path.normpath(
            os.path.join(args.dest_folder, "substrate.dot"))
        if source_path != dest_path:
            shutil.copy(os.path.join(RESULTS_FOLDER, "./substrate.dot"), )
        subprocess.Popen(["eog",
                          os.path.join(args.dest_folder, "topo.svg")]).wait()

else:
Beispiel #4
0
parser.add_argument('--net', dest='net', action='store_true', help="print only the network")
parser.add_argument('--view', dest='view', action='store_true')
parser.add_argument("-s", '--serviceid', type=int)

args = parser.parse_args()

# if not args.net:
#     graphiz_exe="neato"
# else:
#     graphiz_exe="dot"

session = Session()
service = session.query(Service).order_by(Service.id.desc()).all()[0]
service_id = str(service.id)
# service.slas[0].substrate.write(path=str(args.serviceid))

dosvg = args.dosvg
plotsol_from_db(service_link_linewidth=args.service_link_linewidth, net=args.net, service=service)
if not dosvg:
    file = tempfile.mkstemp(".pdf")[1]
    subprocess.Popen(
        ["neato", os.path.join(RESULTS_FOLDER, service_id, "./substrate.dot"), "-Tpdf", "-o", file]).wait()
    if args.view:
        subprocess.Popen(["evince", file]).wait()
else:
    file = args.dest
    subprocess.Popen(
        ["neato", os.path.join(RESULTS_FOLDER, service_id, "./substrate.dot"), "-Tsvg", "-o", file]).wait()
    if args.view:
        subprocess.Popen(["eog", file]).wait()