예제 #1
0
파일: cluster.py 프로젝트: deriamis/pcs
def auth_nodes(nodes):
    if "-u" in utils.pcs_options:
        username = utils.pcs_options["-u"]
    else:
        username = None

    if "-p" in utils.pcs_options:
        password = utils.pcs_options["-p"]
    else:
        password = None

    for node in nodes:
        status = utils.checkAuthorization(node)
        if status[0] == 3 or "--force" in utils.pcs_options:
            if username == None:
                sys.stdout.write('Username: ')
                sys.stdout.flush()
                username = raw_input("")
            if password == None:
                if sys.stdout.isatty():
                    password = getpass.getpass("Password: "******"")
            utils.updateToken(node,nodes,username,password)
            print "%s: Authorized" % (node)
        elif status[0] == 0:
            print node + ": Already authorized"
        else:
            utils.err("Unable to communicate with %s" % (node))
예제 #2
0
파일: cluster.py 프로젝트: lyon667/pcs
def auth_nodes(nodes):
    if "-u" in utils.pcs_options:
        username = utils.pcs_options["-u"]
    else:
        username = None

    if "-p" in utils.pcs_options:
        password = utils.pcs_options["-p"]
    else:
        password = None

    for node in nodes:
        status = utils.checkStatus(node)
        if status[0] == 0:
            print node + ": Already authorized"
        elif status[0] == 3:
            if username == None:
                username = raw_input("Username: "******"Password: "******"%s: Authorized" % (node)
        else:
            print "Unable to communicate with %s" % (node)
            exit(1)
예제 #3
0
def auth_nodes(nodes):
    if "-u" in utils.pcs_options:
        username = utils.pcs_options["-u"]
    else:
        username = None

    if "-p" in utils.pcs_options:
        password = utils.pcs_options["-p"]
    else:
        password = None

    for node in nodes:
        status = utils.checkAuthorization(node)
        if status[0] == 0:
            print node + ": Already authorized"
        elif status[0] == 3:
            if username == None:
                username = raw_input("Username: "******"Password: "******"%s: Authorized" % (node)
        else:
            print "Unable to communicate with %s" % (node)
            exit(1)
예제 #4
0
파일: cluster.py 프로젝트: nozawat/pcs
def auth_nodes(nodes):
    for node in nodes:
        status = utils.checkStatus(node)
        if status[0] == 0:
            print node + ": Already authorized"
        elif status[0] == 3:
            utils.updateToken(node)
            print "%s: Authorized" % (node)
        else:
            print "Unable to communicate with %s" % (node)
            exit(1)
예제 #5
0
파일: cluster.py 프로젝트: MichalCab/pcs
def auth_nodes(nodes):
    if "-u" in utils.pcs_options:
        username = utils.pcs_options["-u"]
    else:
        username = None

    if "-p" in utils.pcs_options:
        password = utils.pcs_options["-p"]
    else:
        password = None

    set_nodes = set(nodes)
    for node in nodes:
        status = utils.checkAuthorization(node)
        need_auth = status[0] == 3 or "--force" in utils.pcs_options
        mutually_authorized = False
        if status[0] == 0:
            try:
                auth_status = json.loads(status[1])
                if auth_status["success"]:
                    if set_nodes == set(auth_status["node_list"]):
                        mutually_authorized = True
            except ValueError, KeyError:
                pass
        if need_auth or not mutually_authorized:
            if username == None:
                sys.stdout.write('Username: ')
                sys.stdout.flush()
                username = raw_input("")
            if password == None:
                if sys.stdout.isatty():
                    password = getpass.getpass("Password: "******"")
            utils.updateToken(node,nodes,username,password)
            print "%s: Authorized" % (node)
        elif mutually_authorized:
            print node + ": Already authorized"
        else:
            utils.err("Unable to communicate with %s" % (node), False)