diff --git a/capsulflask/db.py b/capsulflask/db.py index d2412bb..60cc103 100644 --- a/capsulflask/db.py +++ b/capsulflask/db.py @@ -14,7 +14,7 @@ def init_app(app): databaseUrl = urlparse(app.config['DATABASE_URL']) app.config['PSYCOPG2_CONNECTION_POOL'] = psycopg2.pool.SimpleConnectionPool( - 1, + 1, 20, user = databaseUrl.username, password = databaseUrl.password, @@ -34,13 +34,13 @@ def init_app(app): key = result.group() with open(join(schemaMigrationsPath, filename), 'rb') as file: schemaMigrations[key] = file.read().decode("utf8") - + connection = app.config['PSYCOPG2_CONNECTION_POOL'].getconn() hasSchemaVersionTable = False actionWasTaken = False schemaVersion = 0 - desiredSchemaVersion = 7 + desiredSchemaVersion = 8 cursor = connection.cursor() @@ -95,11 +95,11 @@ def init_app(app): if schemaVersion != versionFromDatabase: app.logger.critical("incorrect schema version value \"{}\" after running migration {}, expected \"{}\". exiting.".format( versionFromDatabase, - migrationKey, + migrationKey, schemaVersion )) exit(1) - + cursor.close() app.config['PSYCOPG2_CONNECTION_POOL'].putconn(connection) diff --git a/capsulflask/schema_migrations/08_down_various_os_updates.sql b/capsulflask/schema_migrations/08_down_various_os_updates.sql new file mode 100644 index 0000000..8de4d85 --- /dev/null +++ b/capsulflask/schema_migrations/08_down_various_os_updates.sql @@ -0,0 +1,34 @@ +DELETE FROM os_images WHERE id = 'openbsd68'; +DELETE FROM os_images WHERE id = 'alpine312'; + +UPDATE os_images SET deprecated = FALSE WHERE id = 'openbsd67'; +UPDATE os_images SET deprecated = FALSE WHERE id = 'alpine311'; + +UPDATE os_images SET template_image_file_name = 'alpine311.img' +WHERE id = 'alpine311'; + +UPDATE os_images SET template_image_file_name = 'ubuntu-18.04-minimal-cloudimg-amd64.img' +WHERE id = 'ubuntu18'; + +UPDATE os_images SET template_image_file_name = 'openbsd-cloud-2020-05.qcow2' +WHERE id = 'openbsd66'; + +UPDATE os_images SET template_image_file_name = 'openbsd67.img' +WHERE id = 'openbsd67'; + +UPDATE os_images SET template_image_file_name = 'ubuntu20.img' +WHERE id = 'ubuntu20'; + +UPDATE os_images SET template_image_file_name = 'debian10.img' +WHERE id = 'debian10'; + +UPDATE os_images SET template_image_file_name = 'centos7.img' +WHERE id = 'centos7'; + +UPDATE os_images SET template_image_file_name = 'centos8.img' +WHERE id = 'centos8'; + +UPDATE os_images SET template_image_file_name = 'guixsystem-cloud-2020-05.qcow2' +WHERE id = 'guix110'; + +UPDATE schemaversion SET version = 7; diff --git a/capsulflask/schema_migrations/08_up_various_os_updates.sql b/capsulflask/schema_migrations/08_up_various_os_updates.sql new file mode 100644 index 0000000..6ccce04 --- /dev/null +++ b/capsulflask/schema_migrations/08_up_various_os_updates.sql @@ -0,0 +1,37 @@ +INSERT INTO os_images (id, template_image_file_name, description, deprecated) +VALUES ('openbsd68', 'openbsd/6.8/root.img.qcow2', 'OpenBSD 6.8', FALSE); + +INSERT INTO os_images (id, template_image_file_name, description, deprecated) +VALUES ('alpine312', 'alpine/3.12/root.img.qcow2', 'Alpine Linux 3.12', FALSE); + +UPDATE os_images SET deprecated = TRUE WHERE id = 'openbsd67'; +UPDATE os_images SET deprecated = TRUE WHERE id = 'alpine311'; + +UPDATE os_images SET template_image_file_name = 'alpine/3.11/root.img.qcow2' +WHERE id = 'alpine311'; + +UPDATE os_images SET template_image_file_name = 'ubuntu/18.04/root.img.qcow2' +WHERE id = 'ubuntu18'; + +UPDATE os_images SET template_image_file_name = 'openbsd/6.6/root.img.qcow2' +WHERE id = 'openbsd66'; + +UPDATE os_images SET template_image_file_name = 'openbsd/6.7/root.img.qcow2' +WHERE id = 'openbsd67'; + +UPDATE os_images SET template_image_file_name = 'ubuntu/20.04/root.img.qcow2' +WHERE id = 'ubuntu20'; + +UPDATE os_images SET template_image_file_name = 'debian/10/root.img.qcow2' +WHERE id = 'debian10'; + +UPDATE os_images SET template_image_file_name = 'centos/7/root.img.qcow2' +WHERE id = 'centos7'; + +UPDATE os_images SET template_image_file_name = 'centos/8/root.img.qcow2' +WHERE id = 'centos8'; + +UPDATE os_images SET template_image_file_name = 'guix/1.10/root.img.qcow2' +WHERE id = 'guix110'; + +UPDATE schemaversion SET version = 8; diff --git a/capsulflask/shell_scripts/create.sh b/capsulflask/shell_scripts/create.sh index dacee42..2a7760f 100755 --- a/capsulflask/shell_scripts/create.sh +++ b/capsulflask/shell_scripts/create.sh @@ -5,8 +5,7 @@ # POSIX or die vmname="$1" -# resolve the .qcow2 symlink so backing images never change -template_file="/tank/img/$(readlink /tank/img/$2)" +template_file="/tank/img/$2" vcpus="$3" memory="$4" pubkeys="$5" @@ -48,7 +47,7 @@ if [ -f /tank/vm/$vmname.qcow2 ]; then exit 1 fi -qemu-img create -f qcow2 -b "$template_file" "$disk" +cp "$template_file" "$disk" cp /tank/config/cyberia-cloudinit.yml /tmp/cloudinit.yml echo "$pubkeys" | while IFS= read -r line; do echo " - $line" >> /tmp/cloudinit.yml diff --git a/capsulflask/templates/changelog.html b/capsulflask/templates/changelog.html index 685bc5d..6615055 100644 --- a/capsulflask/templates/changelog.html +++ b/capsulflask/templates/changelog.html @@ -8,18 +8,21 @@ {% block subcontent %}

{% endblock %} diff --git a/capsulflask/templates/faq.html b/capsulflask/templates/faq.html index 40f36f5..d6b7d04 100644 --- a/capsulflask/templates/faq.html +++ b/capsulflask/templates/faq.html @@ -11,65 +11,21 @@

diff --git a/capsulflask/templates/support.html b/capsulflask/templates/support.html index ed16bd2..07888f1 100644 --- a/capsulflask/templates/support.html +++ b/capsulflask/templates/support.html @@ -7,7 +7,7 @@

SUPPORT

- support@cyberia.club + support@cyberia.club
{% endblock %} @@ -17,7 +17,7 @@ https://lists.cyberia.club/~cyberia/support

- If you do not want your mail to appear in a public archive, email capsul@cyberia.club instead. + If you do not want your mail to appear in a public archive, email capsul@cyberia.club instead.

Please describe your problem or feature request, and we will do our best to get back to you promptly. Thank you very much. diff --git a/capsulflask/virt_model.py b/capsulflask/virt_model.py index 2bf8d9a..8ff74cc 100644 --- a/capsulflask/virt_model.py +++ b/capsulflask/virt_model.py @@ -111,10 +111,10 @@ class ShellScriptVirtualization(VirtualizationInterface): def create(self, email: str, id: str, template_image_file_name: str, vcpus: int, memory_mb: int, ssh_public_keys: list): validate_capsul_id(id) - if not re.match(r"^[a-zA-Z0-9_.-]+$", template_image_file_name): - raise ValueError(f"template_image_file_name \"{template_image_file_name}\" must match \"^[a-zA-Z0-9_.-]+$\"") + if not re.match(r"^[a-zA-Z0-9/_.-]+$", template_image_file_name): + raise ValueError(f"template_image_file_name \"{template_image_file_name}\" must match \"^[a-zA-Z0-9/_.-]+$\"") - for ssh_public_key in ssh_public_keys: + for ssh_public_key in ssh_public_keys: if not re.match(r"^(ssh|ecdsa)-[0-9A-Za-z+/_=@. -]+$", ssh_public_key): raise ValueError(f"ssh_public_key \"{ssh_public_key}\" must match \"^(ssh|ecdsa)-[0-9A-Za-z+/_=@. -]+$\"")