This commit is contained in:
parent
6963e22933
commit
bcd1190f50
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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 & API Keys</a>
|
||||
<a href="/console/account-balance">Account Balance</a>
|
||||
{% endif %}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user