From 44874b9056015837e84437d4fad5a06a01e0b5ca Mon Sep 17 00:00:00 2001 From: 3wc <3wc.cyberia@doesthisthing.work> Date: Sun, 11 Jul 2021 12:35:35 +0200 Subject: [PATCH] Updates for upstream IP handling --- capsulflask/console.py | 2 +- capsulflask/publicapi.py | 4 +++- capsulflask/schema_migrations/16_down_api_tokens.py | 2 -- capsulflask/schema_migrations/17_down_api_tokens.py | 2 ++ .../{16_up_api_tokens.py => 17_up_api_tokens.py} | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) delete mode 100644 capsulflask/schema_migrations/16_down_api_tokens.py create mode 100644 capsulflask/schema_migrations/17_down_api_tokens.py rename capsulflask/schema_migrations/{16_up_api_tokens.py => 17_up_api_tokens.py} (87%) diff --git a/capsulflask/console.py b/capsulflask/console.py index c7aa24c..0105177 100644 --- a/capsulflask/console.py +++ b/capsulflask/console.py @@ -236,7 +236,7 @@ def _create(vm_sizes, operating_systems, public_keys_for_account, server_data): """) if len(errors) == 0: - id = makeCapsulId() + id = make_capsul_id() get_model().create_vm( email=session["account"], id=id, diff --git a/capsulflask/publicapi.py b/capsulflask/publicapi.py index 413a06a..90c12ec 100644 --- a/capsulflask/publicapi.py +++ b/capsulflask/publicapi.py @@ -10,7 +10,7 @@ from nanoid import generate from capsulflask.auth import account_required 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"]) @account_required @@ -25,6 +25,8 @@ def capsul_create(): account_balance = get_account_balance(get_vms(), get_payments(), datetime.datetime.utcnow()) capacity_avaliable = current_app.config["HUB_MODEL"].capacity_avaliable(512*1024*1024) + request.json['ssh_authorized_key_count'] = 1 + id, errors = _create( vm_sizes, operating_systems, diff --git a/capsulflask/schema_migrations/16_down_api_tokens.py b/capsulflask/schema_migrations/16_down_api_tokens.py deleted file mode 100644 index 5f3f93e..0000000 --- a/capsulflask/schema_migrations/16_down_api_tokens.py +++ /dev/null @@ -1,2 +0,0 @@ -DROP TABLE api_keys; -UPDATE schemaversion SET version = 15; diff --git a/capsulflask/schema_migrations/17_down_api_tokens.py b/capsulflask/schema_migrations/17_down_api_tokens.py new file mode 100644 index 0000000..c915d4a --- /dev/null +++ b/capsulflask/schema_migrations/17_down_api_tokens.py @@ -0,0 +1,2 @@ +DROP TABLE api_keys; +UPDATE schemaversion SET version = 16; diff --git a/capsulflask/schema_migrations/16_up_api_tokens.py b/capsulflask/schema_migrations/17_up_api_tokens.py similarity index 87% rename from capsulflask/schema_migrations/16_up_api_tokens.py rename to capsulflask/schema_migrations/17_up_api_tokens.py index ae15dbd..e17d67e 100644 --- a/capsulflask/schema_migrations/16_up_api_tokens.py +++ b/capsulflask/schema_migrations/17_up_api_tokens.py @@ -6,4 +6,4 @@ CREATE TABLE api_tokens ( token TEXT NOT NULL ); -UPDATE schemaversion SET version = 16; +UPDATE schemaversion SET version = 17;