Example #1
0
def run_testConnection():
    
    if request.method == 'POST':

        jsonData = request.get_json()
        
        ccp = CCP("https://" + jsonData['ipAddress'],jsonData['username'],jsonData['password'])

        
        # vip pools UUID still requires the v2 API so you need to login for both the v2 and v3 API until the vip pools has been moved to v3
               
        loginV2 = ccp.loginV2()
        loginV3 = ccp.loginV3()

        if not loginV2 and not loginV3:
            socketio.emit('consoleLog', {'loggingType': 'ERROR','loggingMessage': config.ERROR_CCP_LOGIN })
            return json.dumps({'success':False}), 401, {'ContentType':'application/json'} 
        else:
            session['ccpURL'] = "https://" + jsonData['ipAddress']
            session['ccpToken'] = loginV2.cookies.get_dict()
            session['sessionUUID'] =  uuid.UUID(bytes=secrets.token_bytes(16))
            session['x-auth-token'] = loginV3

            socketio.emit('consoleLog', {'loggingType': 'INFO','loggingMessage': config.INFO_CCP_LOGIN })
            return jsonify(dict(redirectURL='/ccpClusterCreation'))
    
    return render_template('ccpLogin.html')
Example #2
0
def run_ccpLogin():

    if request.method == 'POST':

        ccp = CCP("https://" + request.form['IP Address'],request.form['Username'],request.form['Password'])
                
        loginV2 = ccp.loginV2()
        loginV3 = ccp.loginV3()

        if not loginV2 and not loginV3:
            print ("There was an issue with login: "******"https://" + request.form['IP Address']
            session['ccpToken'] = loginV2.cookies.get_dict()
            session['x-auth-token'] = loginV3

            return render_template('ccpClusterCreation.html')

    return render_template('ccpLogin.html')