Fix API 🙈
continuous-integration/drone/push Build is passing Details

This commit is contained in:
3wc 2021-07-29 11:36:58 +02:00
parent 6963e22933
commit bcd1190f50
4 changed files with 11 additions and 5 deletions

View File

@ -189,7 +189,7 @@ def detail(id):
duration=duration
)
def _create(vm_sizes, operating_systems, public_keys_for_account, affordable_vm_sizes, server_data):
def _create(email, vm_sizes, operating_systems, public_keys_for_account, affordable_vm_sizes, server_data):
errors = list()
size = server_data.get("size")
@ -241,14 +241,14 @@ def _create(vm_sizes, operating_systems, public_keys_for_account, affordable_vm_
if len(errors) == 0:
id = make_capsul_id()
current_app.config["HUB_MODEL"].create(
email = session["account"],
email = email,
id=id,
os=os,
size=size,
template_image_file_name=operating_systems[os]['template_image_file_name'],
vcpus=vm_sizes[size]['vcpus'],
memory_mb=vm_sizes[size]['memory_mb'],
ssh_authorized_keys=posted_keys
ssh_authorized_keys=list(map(lambda x: dict(name=x['name'], content=x['content']), posted_keys))
)
return id, errors
@ -276,6 +276,7 @@ def create():
if "csrf-token" not in request.form or request.form['csrf-token'] != session['csrf-token']:
return abort(418, f"u want tea")
id, errors = _create(
session['account'],
vm_sizes,
operating_systems,
public_keys_for_account,

View File

@ -198,6 +198,10 @@ class CapsulFlaskHub(VirtualizationInterface):
validate_capsul_id(id)
online_hosts = get_model().get_online_hosts()
#current_app.logger.debug(f"hub_model.create(): ${len(online_hosts)} hosts")
current_app.logger.error(f'{email}, {id} {os} {size} {template_image_file_name} {vcpus} {memory_mb}')
current_app.logger.error(f'{ssh_authorized_keys}')
payload = json.dumps(dict(
type="create",
email=email,

View File

@ -15,7 +15,7 @@ bp = Blueprint("publicapi", __name__, url_prefix="/api")
@bp.route("/capsul/create", methods=["POST"])
@account_required
def capsul_create():
email = session["account"]
email = session["account"][0]
from .console import _create, get_account_balance, get_payments, get_vms
@ -36,6 +36,7 @@ def capsul_create():
request.json['ssh_authorized_key_count'] = 1
id, errors = _create(
email,
vm_sizes,
operating_systems,
public_keys_for_account,

View File

@ -31,7 +31,7 @@
{% if session["account"] %}
<a href="/console">Capsuls</a>
<a href="/console/ssh">SSH Public Keys</a>
<a href="/console/keys">SSH &amp; API Keys</a>
<a href="/console/account-balance">Account Balance</a>
{% endif %}