forked from 3wordchant/capsul-flask
Updates for upstream IP handling
This commit is contained in:
parent
e6a14f8626
commit
aa1a9f558b
@ -236,17 +236,12 @@ def _create(vm_sizes, operating_systems, public_keys_for_account, server_data):
|
|||||||
""")
|
""")
|
||||||
|
|
||||||
if len(errors) == 0:
|
if len(errors) == 0:
|
||||||
id = makeCapsulId()
|
id = make_capsul_id()
|
||||||
get_model().create_vm(
|
|
||||||
email=session["account"],
|
|
||||||
id=id,
|
|
||||||
size=size,
|
|
||||||
os=os,
|
|
||||||
ssh_authorized_keys=list(map(lambda x: x["name"], posted_keys))
|
|
||||||
)
|
|
||||||
current_app.config["HUB_MODEL"].create(
|
current_app.config["HUB_MODEL"].create(
|
||||||
email = session["account"],
|
email = session["account"],
|
||||||
id=id,
|
id=id,
|
||||||
|
os=os,
|
||||||
|
size=size,
|
||||||
template_image_file_name=operating_systems[os]['template_image_file_name'],
|
template_image_file_name=operating_systems[os]['template_image_file_name'],
|
||||||
vcpus=vm_sizes[size]['vcpus'],
|
vcpus=vm_sizes[size]['vcpus'],
|
||||||
memory_mb=vm_sizes[size]['memory_mb'],
|
memory_mb=vm_sizes[size]['memory_mb'],
|
||||||
@ -264,6 +259,7 @@ def create():
|
|||||||
public_keys_for_account = get_model().list_ssh_public_keys_for_account(session["account"])
|
public_keys_for_account = get_model().list_ssh_public_keys_for_account(session["account"])
|
||||||
account_balance = get_account_balance(get_vms(), get_payments(), datetime.utcnow())
|
account_balance = get_account_balance(get_vms(), get_payments(), datetime.utcnow())
|
||||||
capacity_avaliable = current_app.config["HUB_MODEL"].capacity_avaliable(512*1024*1024)
|
capacity_avaliable = current_app.config["HUB_MODEL"].capacity_avaliable(512*1024*1024)
|
||||||
|
errors = list()
|
||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
if "csrf-token" not in request.form or request.form['csrf-token'] != session['csrf-token']:
|
if "csrf-token" not in request.form or request.form['csrf-token'] != session['csrf-token']:
|
||||||
|
@ -43,7 +43,7 @@ def init_app(app, is_running_server):
|
|||||||
hasSchemaVersionTable = False
|
hasSchemaVersionTable = False
|
||||||
actionWasTaken = False
|
actionWasTaken = False
|
||||||
schemaVersion = 0
|
schemaVersion = 0
|
||||||
desiredSchemaVersion = 18
|
desiredSchemaVersion = 19
|
||||||
|
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ from nanoid import generate
|
|||||||
from capsulflask.auth import account_required
|
from capsulflask.auth import account_required
|
||||||
from capsulflask.db import get_model
|
from capsulflask.db import get_model
|
||||||
|
|
||||||
bp = Blueprint("webapi", __name__, url_prefix="/api")
|
bp = Blueprint("publicapi", __name__, url_prefix="/api")
|
||||||
|
|
||||||
@bp.route("/capsul/create", methods=["POST"])
|
@bp.route("/capsul/create", methods=["POST"])
|
||||||
@account_required
|
@account_required
|
||||||
@ -25,6 +25,8 @@ def capsul_create():
|
|||||||
account_balance = get_account_balance(get_vms(), get_payments(), datetime.datetime.utcnow())
|
account_balance = get_account_balance(get_vms(), get_payments(), datetime.datetime.utcnow())
|
||||||
capacity_avaliable = current_app.config["HUB_MODEL"].capacity_avaliable(512*1024*1024)
|
capacity_avaliable = current_app.config["HUB_MODEL"].capacity_avaliable(512*1024*1024)
|
||||||
|
|
||||||
|
request.json['ssh_authorized_key_count'] = 1
|
||||||
|
|
||||||
id, errors = _create(
|
id, errors = _create(
|
||||||
vm_sizes,
|
vm_sizes,
|
||||||
operating_systems,
|
operating_systems,
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
DROP TABLE api_keys;
|
|
||||||
UPDATE schemaversion SET version = 15;
|
|
2
capsulflask/schema_migrations/19_down_api_tokens.py
Normal file
2
capsulflask/schema_migrations/19_down_api_tokens.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
DROP TABLE api_keys;
|
||||||
|
UPDATE schemaversion SET version = 18;
|
@ -6,4 +6,4 @@ CREATE TABLE api_tokens (
|
|||||||
token TEXT NOT NULL
|
token TEXT NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
UPDATE schemaversion SET version = 16;
|
UPDATE schemaversion SET version = 19;
|
Loading…
Reference in New Issue
Block a user