This commit is contained in:
parent
6963e22933
commit
bcd1190f50
@ -189,7 +189,7 @@ def detail(id):
|
|||||||
duration=duration
|
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()
|
errors = list()
|
||||||
|
|
||||||
size = server_data.get("size")
|
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:
|
if len(errors) == 0:
|
||||||
id = make_capsul_id()
|
id = make_capsul_id()
|
||||||
current_app.config["HUB_MODEL"].create(
|
current_app.config["HUB_MODEL"].create(
|
||||||
email = session["account"],
|
email = email,
|
||||||
id=id,
|
id=id,
|
||||||
os=os,
|
os=os,
|
||||||
size=size,
|
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'],
|
||||||
ssh_authorized_keys=posted_keys
|
ssh_authorized_keys=list(map(lambda x: dict(name=x['name'], content=x['content']), posted_keys))
|
||||||
)
|
)
|
||||||
return id, errors
|
return id, errors
|
||||||
|
|
||||||
@ -276,6 +276,7 @@ def create():
|
|||||||
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']:
|
||||||
return abort(418, f"u want tea")
|
return abort(418, f"u want tea")
|
||||||
id, errors = _create(
|
id, errors = _create(
|
||||||
|
session['account'],
|
||||||
vm_sizes,
|
vm_sizes,
|
||||||
operating_systems,
|
operating_systems,
|
||||||
public_keys_for_account,
|
public_keys_for_account,
|
||||||
|
@ -198,6 +198,10 @@ class CapsulFlaskHub(VirtualizationInterface):
|
|||||||
validate_capsul_id(id)
|
validate_capsul_id(id)
|
||||||
online_hosts = get_model().get_online_hosts()
|
online_hosts = get_model().get_online_hosts()
|
||||||
#current_app.logger.debug(f"hub_model.create(): ${len(online_hosts)} 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(
|
payload = json.dumps(dict(
|
||||||
type="create",
|
type="create",
|
||||||
email=email,
|
email=email,
|
||||||
|
@ -15,7 +15,7 @@ bp = Blueprint("publicapi", __name__, url_prefix="/api")
|
|||||||
@bp.route("/capsul/create", methods=["POST"])
|
@bp.route("/capsul/create", methods=["POST"])
|
||||||
@account_required
|
@account_required
|
||||||
def capsul_create():
|
def capsul_create():
|
||||||
email = session["account"]
|
email = session["account"][0]
|
||||||
|
|
||||||
from .console import _create, get_account_balance, get_payments, get_vms
|
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
|
request.json['ssh_authorized_key_count'] = 1
|
||||||
|
|
||||||
id, errors = _create(
|
id, errors = _create(
|
||||||
|
email,
|
||||||
vm_sizes,
|
vm_sizes,
|
||||||
operating_systems,
|
operating_systems,
|
||||||
public_keys_for_account,
|
public_keys_for_account,
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
{% if session["account"] %}
|
{% if session["account"] %}
|
||||||
<a href="/console">Capsuls</a>
|
<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>
|
<a href="/console/account-balance">Account Balance</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user