예제 #1
0
파일: xtxml.py 프로젝트: zagura/xorp.ct
def main():
    def usage():
	print us % sys.argv[0]
    try:
	opts, args = getopt.getopt(sys.argv[1:], "hvp:c:d", \
				   ["help", "values", "physical=", "config=",
                                   "debug"])
    except getopt.GetoptError:
	usage()
	sys.exit(1)

    physical = ""
    config = ""
    debug = 0
    values = 0
    for o, a in opts:
	if o in ("-h", "--help"):
	    usage()
	    sys.exit()
	if o in ("-v", "--values"):
            values = 1
	if o in ("-p", "--physical"):
	    physical = a
	if o in ("-c", "--config"):
	    config = a
	if o in ("-d", "--debug"):
	    debug = 1

    p = 0
    if "" == physical and "" == config:
        p = Physical(debug)
        physical = p.get()

    if "" != physical:
        c = Xtphysical(physical, debug).start()
        for i in c:
            if 1 == values:
                print i.values()
            else:
                print i

    if p:
        p.remove()
    
    if "" != config:
        c, k, n, r = Xtconfig(config, debug).start()
        for i in c:
            if 1 == values:
                print i.values()
            else:
                print i
        for i in k:
            print i
        for i in n:
            print i
        if r:
            print r
        
    sys.exit()
예제 #2
0
def main():

    def usage():
        global us
	print us % sys.argv[0]
    try:
	opts, args = getopt.getopt(sys.argv[1:], "hsDrRIgvip:f:c:d", \
				   ["help", "switch", "default", \
                                   "reboot", \
                                   "REBOOT", \
                                   "install", \
                                    "generate", \
                                    "verify", \
                                    "ifcheck", \
                                    "physical=", "fancy=", "config=", \
                                    "debug"])
    except getopt.GetoptError:
	usage()
	sys.exit(1)

    default = 0
    reboot = 0
    inst = 0
    gen = 0
    switch = 0
    verify = 0
    ifcheckp = 0
    physical = ""
    fancy = ""
    config = ""
    debug = 0
    for o, a in opts:
	if o in ("-h", "--help"):
	    usage()
	    sys.exit()
	if o in ("-D", "--default"):
	    default = 1
	if o in ("-r", "--reboot"):
	    reboot = 1
	if o in ("-R", "--REBOOT"):
	    reboot = 2
	if o in ("-I", "--install"):
	    inst = 1
	if o in ("-g", "--generate"):
	    gen = 1
        if o in ("-s", "--switch"):
            switch = 1
        if o in ("-v", "--verify"):
            verify = 1
        if o in ("-i", "--ifcheck"):
            ifcheckp = 1
	if o in ("-p", "--physical"):
	    physical = a
	if o in ("-f", "--fancy"):
	    fancy = a
	if o in ("-c", "--config"):
	    config = a
	if o in ("-d", "--debug"):
	    debug = 1

    p = 0
    if "" == physical:
        p = Physical(debug)
        physical = p.get()

    if 1==default:
        if "" != physical:
            Defaults(physical, debug).start()
        else:
            usage()

    if 1==inst:
        if "" != physical and "" != fancy:
            install(physical, fancy, reboot, debug)
        else:
            usage()

    if 1==gen:
        if "" != physical and "" != fancy:
            generate(physical, fancy, debug)
        else:
            usage()

    if 1==switch:
        if "" != config:
            HPConfig(config, os.path.abspath(config), debug).start()
        else:
            usage()

    if 1==verify:
        if "" != physical and "" != config:
            Verify(physical, config, debug).start()
        else:
            usage()

    if 1==ifcheckp:
        if "" != physical:
            ifcheck(physical, debug)
        else:
            usage()

    if p:
        p.remove()

    sys.exit(0)
예제 #3
0
파일: xtconf.py 프로젝트: zagura/xorp.ct
def main():
    def usage():
        global us
        print us % sys.argv[0]

    try:
        opts, args = getopt.getopt(sys.argv[1:], "hsDrRIgvip:f:c:d", \
              ["help", "switch", "default", \
                                          "reboot", \
                                          "REBOOT", \
                                          "install", \
                                           "generate", \
                                           "verify", \
                                           "ifcheck", \
                                           "physical=", "fancy=", "config=", \
                                           "debug"])
    except getopt.GetoptError:
        usage()
        sys.exit(1)

    default = 0
    reboot = 0
    inst = 0
    gen = 0
    switch = 0
    verify = 0
    ifcheckp = 0
    physical = ""
    fancy = ""
    config = ""
    debug = 0
    for o, a in opts:
        if o in ("-h", "--help"):
            usage()
            sys.exit()
        if o in ("-D", "--default"):
            default = 1
        if o in ("-r", "--reboot"):
            reboot = 1
        if o in ("-R", "--REBOOT"):
            reboot = 2
        if o in ("-I", "--install"):
            inst = 1
        if o in ("-g", "--generate"):
            gen = 1
        if o in ("-s", "--switch"):
            switch = 1
        if o in ("-v", "--verify"):
            verify = 1
        if o in ("-i", "--ifcheck"):
            ifcheckp = 1
        if o in ("-p", "--physical"):
            physical = a
        if o in ("-f", "--fancy"):
            fancy = a
        if o in ("-c", "--config"):
            config = a
        if o in ("-d", "--debug"):
            debug = 1

    p = 0
    if "" == physical:
        p = Physical(debug)
        physical = p.get()

    if 1 == default:
        if "" != physical:
            Defaults(physical, debug).start()
        else:
            usage()

    if 1 == inst:
        if "" != physical and "" != fancy:
            install(physical, fancy, reboot, debug)
        else:
            usage()

    if 1 == gen:
        if "" != physical and "" != fancy:
            generate(physical, fancy, debug)
        else:
            usage()

    if 1 == switch:
        if "" != config:
            HPConfig(config, os.path.abspath(config), debug).start()
        else:
            usage()

    if 1 == verify:
        if "" != physical and "" != config:
            Verify(physical, config, debug).start()
        else:
            usage()

    if 1 == ifcheckp:
        if "" != physical:
            ifcheck(physical, debug)
        else:
            usage()

    if p:
        p.remove()

    sys.exit(0)