mirror of
https://github.com/ComputerScienceHouse/proxstar.git
synced 2025-03-09 15:40:09 +00:00
add SSH key check
This commit is contained in:
parent
8bf49a664a
commit
2693f6f138
1 changed files with 4 additions and 1 deletions
|
@ -267,6 +267,7 @@ $("#create-vm").click(function(){
|
||||||
const max_cpu = $(this).data('max_cpu');
|
const max_cpu = $(this).data('max_cpu');
|
||||||
const max_mem = $(this).data('max_mem');
|
const max_mem = $(this).data('max_mem');
|
||||||
const max_disk = $(this).data('max_disk');
|
const max_disk = $(this).data('max_disk');
|
||||||
|
var ssh_regex = new RegExp("ssh-rsa AAAA[0-9A-Za-z+/]+[=]{0,3}( [^@]+@[^@]+)?")
|
||||||
var disk = document.getElementById('disk').value;
|
var disk = document.getElementById('disk').value;
|
||||||
fetch(`/template/${template}/disk`, {
|
fetch(`/template/${template}/disk`, {
|
||||||
credentials: 'same-origin',
|
credentials: 'same-origin',
|
||||||
|
@ -279,7 +280,9 @@ $("#create-vm").click(function(){
|
||||||
return disk
|
return disk
|
||||||
}).then((disk) => {
|
}).then((disk) => {
|
||||||
if (name && disk) {
|
if (name && disk) {
|
||||||
if (disk > max_disk) {
|
if (!ssh_regex.test(ssh_key)) {
|
||||||
|
swal("Uh oh...", "Invalid SSH key!", "error");
|
||||||
|
} else if (disk > max_disk) {
|
||||||
swal("Uh oh...", `You do not have enough disk resources available! Please lower the VM disk size to ${max_disk}GB or lower.`, "error");
|
swal("Uh oh...", `You do not have enough disk resources available! Please lower the VM disk size to ${max_disk}GB or lower.`, "error");
|
||||||
} else if (template != 'none' && cores > max_cpu) {
|
} else if (template != 'none' && cores > max_cpu) {
|
||||||
swal("Uh oh...", `You do not have enough CPU resources available! Please lower the VM cores to ${max_cpu} or lower.`, "error");
|
swal("Uh oh...", `You do not have enough CPU resources available! Please lower the VM cores to ${max_cpu} or lower.`, "error");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue