def configure_flavors():
    # check configuration
    settings = Status().check_settings()

    # load flavors
    flavors = db.session.query(Flavors).all()

    # how much is BTC?
    try:
        quote = float(coinbase_get_quote(currency="btc_to_usd")["result"]["btc_to_usd"]) / 1000000
    except:
        quote = 0

    return render_template("configure/flavors.html", settings=settings, quote=quote, flavors=flavors)
def configure_flavors_detail(flavor_id):
    # get the matching flavor
    flavor = db.session.query(Flavors).filter_by(id=flavor_id).first()

    # handle a GET
    if request.method == 'GET':
        # check configuration
        settings = Status().check_settings()

        # how much is a micro BTC?
        try:
            quote = float(
                coinbase_get_quote(
                    currency='btc_to_usd')['result']['btc_to_usd']) / 1000000
        except:
            quote = 0

        return render_template('/configure/flavor_detail.html',
                               settings=settings,
                               quote=quote,
                               flavor=flavor)

    # handle a PUT
    elif request.method == 'PUT':
        # clear settings cache
        Status().flush()

        try:
            state = int(request.form['enable'])
            flavor.active = state

            # set instances with this flavor to the state
            instances = Instances()
            instances.toggle(flavor.id, state)

        except:
            pass

        try:
            ask = request.form['ask']
            flavor.ask = ask
        except:
            pass

        # update entry
        flavor.update()

        return jsonify({"response": "success", "flavor": row2dict(flavor)})
def configure_flavors_detail(flavor_id):
    # get the matching flavor
    flavor = db.session.query(Flavors).filter_by(id=flavor_id).first()

    # handle a GET
    if request.method == "GET":
        # check configuration
        settings = Status().check_settings()

        # how much is a micro BTC?
        try:
            quote = float(coinbase_get_quote(currency="btc_to_usd")["result"]["btc_to_usd"]) / 1000000
        except:
            quote = 0

        return render_template("/configure/flavor_detail.html", settings=settings, quote=quote, flavor=flavor)

        # handle a PUT
    elif request.method == "PUT":
        # clear settings cache
        Status().flush()

        try:
            state = int(request.form["enable"])
            flavor.active = state

            # set instances with this flavor to the state
            instances = Instances()
            instances.toggle(flavor.id, state)

        except:
            pass

        try:
            ask = request.form["ask"]
            flavor.ask = ask
        except:
            pass

            # update entry
        flavor.update()

        return jsonify({"response": "success", "flavor": row2dict(flavor)})
def configure_flavors():
    # check configuration
    settings = Status().check_settings()

    # load flavors
    flavors = db.session.query(Flavors).all()

    # how much is BTC?
    try:
        quote = float(
            coinbase_get_quote(
                currency='btc_to_usd')['result']['btc_to_usd']) / 1000000
    except:
        quote = 0

    return render_template('configure/flavors.html',
                           settings=settings,
                           quote=quote,
                           flavors=flavors)
Beispiel #5
0
def configure_flavors():
    # check configuration
    settings = Status().check_settings()

    # flavors without the ones that were synced from pool are not installed on
    # openstack cluster yet
    flavors = Flavors.query.filter_by(installed=True).all()

    # load appliance
    appliance = Appliance.get()

    # how much is BTC?
    try:
        quote = float(
            coinbase_get_quote(
                currency='btc_to_usd')['result']['btc_to_usd']) / 1000000
    except:
        quote = 0

    return render_template('configure/flavors.html',
                           settings=settings,
                           quote=quote,
                           flavors=flavors,
                           appliance=appliance)
Beispiel #6
0
def configure_flavors():
	# check configuration
	settings = Status().check_settings()

	# flavors without the ones that were synced from pool are not installed on 
	# openstack cluster yet
	flavors = Flavors.query.filter_by(installed=True).all()

	# load appliance
	appliance = Appliance.get()

	# how much is BTC?
	try:
		quote = float(coinbase_get_quote(currency='btc_to_usd')['result']['btc_to_usd'])/1000000
	except:
		quote = 0

	return render_template(
		'configure/flavors.html',
		settings=settings,
		quote=quote,
		flavors=flavors,
		appliance=appliance
	)