Beispiel #1
0
def api_deletions():
    cloud_api_main.tdata.DB_CON = cloud_api_main.open_db2()
    cloud_api_main.tdata.isadmin = True
    everything = ""
    vmdel = "onevm delete {0} \n"
    vnetdel = "onevnet delete {0} \n"

    try:
        for i in cloud_api_main.get_nodes_db().itervalues():
            if i["platform"] == "nebula" and i["internal_id"]:
                everything += vmdel.format(i["internal_id"])

        for i in cloud_api_main.get_networks_db().itervalues():
            everything += vnetdel.format(i["nebulaid"])
    except Exception as e:
        cloud_api_main.debug_log_print("Error:", repr(e))

    return everything
Beispiel #2
0
def api_deletions():
    cloud_api_main.tdata.DB_CON = cloud_api_main.open_db2()
    cloud_api_main.tdata.isadmin = True
    everything = ""
    vmdel = "onevm delete {0} \n"
    vnetdel = "onevnet delete {0} \n"

    try:
        for i in cloud_api_main.get_nodes_db().itervalues():
            if i["platform"] == "nebula" and i["internal_id"]:
                everything += vmdel.format(i["internal_id"])

        for i in cloud_api_main.get_networks_db().itervalues():
            everything += vnetdel.format(i["nebulaid"])
    except Exception as e:
        cloud_api_main.debug_log_print("Error:", repr(e))

    return everything
Beispiel #3
0
def verify_password(username, password):
    cloud_api_main.tdata.extended_error_log = []
    cloud_api_main.tdata.user_info = []

    cloud_api_main.tdata.DB_CON = cloud_api_main.open_db2()
    with cloud_api_main.tdata.DB_CON:
        try:
            res_d = cloud_api_main.get_user(username, verifybypass=True)
        except cloud_api_main.NoSuchObjectException as e:
            res_d = None

        if not res_d:
            return False

        cloud_api_main.tdata.username = username
        cloud_api_main.tdata.isadmin = res_d["isadmin"]
        cloud_api_main.tdata.userid = res_d["id"]
        cloud_api_main.tdata.ownertag = "owner:{0}".format(username)

        # derivedkey = hashlib.pbkdf2_hmac('sha256', password, res_d["salt"], 100000)
        # hexalified = binascii.hexlify(derivedkey)
        hexalified = hashlib.sha512(password + res_d["salt"]).hexdigest()

    return res_d["password"] == hexalified
Beispiel #4
0
def verify_password(username, password):
    cloud_api_main.tdata.extended_error_log = []
    cloud_api_main.tdata.user_info = []

    cloud_api_main.tdata.DB_CON = cloud_api_main.open_db2()
    with cloud_api_main.tdata.DB_CON:
        try:
            res_d = cloud_api_main.get_user(username, verifybypass=True)
        except cloud_api_main.NoSuchObjectException as e:
            res_d = None

        if not res_d:
            return False

        cloud_api_main.tdata.username = username
        cloud_api_main.tdata.isadmin = res_d["isadmin"]
        cloud_api_main.tdata.userid = res_d["id"]
        cloud_api_main.tdata.ownertag = "owner:{0}".format(username)

        # derivedkey = hashlib.pbkdf2_hmac('sha256', password, res_d["salt"], 100000)
        # hexalified = binascii.hexlify(derivedkey)
        hexalified = hashlib.sha512(password + res_d["salt"]).hexdigest()

    return res_d["password"] == hexalified
Beispiel #5
0
    answ["status"] = status

    return make_response(jsonify(answ))




if __name__ == '__main__':
    poller = cloud_api_main.InfoPoller()
    poller.setDaemon(daemonic=True)
    cloud_api_main.debug_log_print("start poller")
    poller.start()
    cloud_api_main.debug_log_print("started poller")

    checker = cloud_api_main.CallbackChecker()
    checker.setDaemon(daemonic=True)
    checker.start()

    time.sleep(1)
    cloud_api_main.tdata.DB_CON = cloud_api_main.open_db2()
    with cloud_api_main.tdata.DB_CON:

        if len(sys.argv) >= 2 and sys.argv[1] == "server":

            callbackdispatcher = cloud_api_main.CallbackDispatcher()
            callbackdispatcher.setDaemon(daemonic=True)
            cloud_api_main.debug_log_print("start callback dispatcher")
            callbackdispatcher.start()
            cloud_api_main.debug_log_print("started callback dispatcher ")

            app.run('0.0.0.0', threaded=True)
Beispiel #6
0
        answ["data"]["description"] = cloud_api_main.get_user_problem_msg()

    answ["status"] = status

    return make_response(jsonify(answ))


if __name__ == '__main__':
    poller = cloud_api_main.InfoPoller()
    poller.setDaemon(daemonic=True)
    cloud_api_main.debug_log_print("start poller")
    poller.start()
    cloud_api_main.debug_log_print("started poller")

    checker = cloud_api_main.CallbackChecker()
    checker.setDaemon(daemonic=True)
    checker.start()

    time.sleep(1)
    cloud_api_main.tdata.DB_CON = cloud_api_main.open_db2()
    with cloud_api_main.tdata.DB_CON:

        if len(sys.argv) >= 2 and sys.argv[1] == "server":

            callbackdispatcher = cloud_api_main.CallbackDispatcher()
            callbackdispatcher.setDaemon(daemonic=True)
            cloud_api_main.debug_log_print("start callback dispatcher")
            callbackdispatcher.start()
            cloud_api_main.debug_log_print("started callback dispatcher ")

            app.run('0.0.0.0', threaded=True)