예제 #1
0
def main(argv):
    parser = ArgumentParser()
    parser.add_argument("indir", help="input dir for topology data")
    parser.add_argument("outfile",
                        nargs='?',
                        default=None,
                        help="output file for rgsummary")
    parser.add_argument("downtimefile",
                        nargs='?',
                        default=None,
                        help="output file for rgdowntime")
    parser.add_argument("--contacts", help="contacts yaml file")
    parser.add_argument(
        "--nostrict",
        action='store_false',
        dest='strict',
        help="Skip files with parse errors (instead of exiting)")
    args = parser.parse_args(argv[1:])

    rgsummary, rgdowntime = get_rgsummary_rgdowntime(args.indir,
                                                     args.contacts,
                                                     authorized=True,
                                                     strict=args.strict)
    if args.outfile:
        with open(args.outfile, "w") as fh:
            fh.write(to_xml(rgsummary))
    else:
        print(to_xml(rgsummary))
    if args.downtimefile:
        with open(args.downtimefile, "w") as fh:
            fh.write(to_xml(rgdowntime))
    else:
        print(to_xml(rgdowntime))

    return 0
예제 #2
0
def main(argv):
    parser = ArgumentParser()
    parser.add_argument("indir", help="input dir for topology data")
    parser.add_argument("outfile", nargs='?', default=None, help="output file for rgsummary")
    parser.add_argument("downtimefile", nargs='?', default=None, help="output file for rgdowntime")
    parser.add_argument("--contacts", help="contacts yaml file")
    args = parser.parse_args(argv[1:])

    try:
        rgsummary, rgdowntime = get_rgsummary_rgdowntime(args.indir, args.contacts,
                                                         authorized=True)
        if args.outfile:
            with open(args.outfile, "w") as fh:
                fh.write(to_xml(rgsummary))
        else:
            print(to_xml(rgsummary))
        if args.downtimefile:
            with open(args.downtimefile, "w") as fh:
                fh.write(to_xml(rgdowntime))
        else:
            print(to_xml(rgdowntime))
    except RGError as e:
        print("Error happened while processing RG:", file=sys.stderr)
        pprint.pprint(e.rg, stream=sys.stderr)
        raise
    except DowntimeError as e:
        print("Error happened while processing downtime:", file=sys.stderr)
        pprint.pprint(e.downtime, stream=sys.stderr)
        print("RG:", file=sys.stderr)
        pprint.pprint(e.rg, stream=sys.stderr)
        raise

    return 0
예제 #3
0
파일: vo_reader.py 프로젝트: zvada/topology
def main(argv):
    parser = ArgumentParser()
    parser.add_argument("indir",
                        help="input dir for virtual-organizations data")
    parser.add_argument("outfile",
                        nargs='?',
                        default=None,
                        help="output file for vosummary")
    parser.add_argument("--contacts", help="contacts yaml file")
    parser.add_argument(
        "--nostrict",
        action='store_false',
        dest='strict',
        help="Skip files with parse errors (instead of exiting)")
    args = parser.parse_args(argv[1:])

    contacts_data = None
    if args.contacts:
        contacts_data = get_contacts_data(args.contacts)
    xml = to_xml(
        get_vos_data(args.indir,
                     contacts_data=contacts_data,
                     strict=args.strict).get_tree(authorized=True))
    if args.outfile:
        with open(args.outfile, "w") as fh:
            fh.write(xml)
    else:
        print(xml)
예제 #4
0
def main(argv):
    parser = ArgumentParser()
    parser.add_argument("infile", help="input file for contacts data")
    parser.add_argument("outfile", nargs='?', default=None, help="output file for miscuser")
    args = parser.parse_args(argv[1:])
    xml = to_xml(get_contacts_data(args.infile).get_tree(authorized=True))
    if args.outfile:
        with open(args.outfile, "w") as fh:
            fh.write(xml)
    else:
        print(xml)
예제 #5
0
def main(argv):
    parser = ArgumentParser()
    parser.add_argument("indir",
                        help="input dir for virtual-organizations data")
    parser.add_argument("outfile",
                        nargs='?',
                        default=None,
                        help="output file for vosummary")
    parser.add_argument("--contacts", help="contacts yaml file")
    args = parser.parse_args(argv[1:])

    contacts_data = None
    if args.contacts:
        contacts_data = get_contacts_data(args.contacts)
    xml = to_xml(
        get_vos_data(args.indir,
                     contacts_data=contacts_data).get_tree(authorized=True))
    if args.outfile:
        with open(args.outfile, "w") as fh:
            fh.write(xml)
    else:
        print(xml)
예제 #6
0
def get_projects_xml(indir="../projects", strict=False):
    """Returns the serialized XML as a string"""
    return to_xml(get_projects(indir, strict=strict))