diff --git a/.gitignore b/.gitignore index 7a40b40..97ac9f2 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ console/cert.pem* tags dhcpd.* webvirtcloud/settings.py +*migrations/* diff --git a/README.md b/README.md index cd5c4e5..ae44568 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ print(''.join([random.SystemRandom().choice(haystack) for _ in range(50)])) ### Install WebVirtCloud panel (Ubuntu) ```bash -sudo apt-get -y install git python-virtualenv python-dev libxml2-dev libvirt-dev zlib1g-dev nginx supervisor libsasl2-modules gcc pkg-config +sudo apt-get -y install git python-virtualenv python-dev python-lxml libvirt-dev zlib1g-dev nginx supervisor libsasl2-modules gcc pkg-config git clone https://github.com/retspen/webvirtcloud cd webvirtcloud cp webvirtcloud/settings.py.template webvirtcloud/settings.py diff --git a/accounts/migrations/0010_auto_20180625_1236.py b/accounts/migrations/0010_auto_20180625_1236.py new file mode 100644 index 0000000..23e1548 --- /dev/null +++ b/accounts/migrations/0010_auto_20180625_1236.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.13 on 2018-06-25 12:36 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0009_auto_20171026_0805'), + ] + + operations = [ + migrations.AlterField( + model_name='userattributes', + name='max_cpus', + field=models.IntegerField(default=1, help_text=b'-1 for unlimited. Any integer value'), + ), + migrations.AlterField( + model_name='userattributes', + name='max_disk_size', + field=models.IntegerField(default=20, help_text=b'-1 for unlimited. Any integer value'), + ), + migrations.AlterField( + model_name='userattributes', + name='max_instances', + field=models.IntegerField(default=1, help_text=b'-1 for unlimited. Any integer value'), + ), + migrations.AlterField( + model_name='userattributes', + name='max_memory', + field=models.IntegerField(default=2048, help_text=b'-1 for unlimited. Any integer value'), + ), + ] diff --git a/accounts/migrations/0011_auto_20180625_1313.py b/accounts/migrations/0011_auto_20180625_1313.py new file mode 100644 index 0000000..1ee194b --- /dev/null +++ b/accounts/migrations/0011_auto_20180625_1313.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.13 on 2018-06-25 13:13 +from __future__ import unicode_literals + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0010_auto_20180625_1236'), + ] + + operations = [ + migrations.AlterField( + model_name='userattributes', + name='max_cpus', + field=models.IntegerField(default=1, help_text=b'-1 for unlimited. Any integer value', validators=[django.core.validators.MinValueValidator(-1)]), + ), + migrations.AlterField( + model_name='userattributes', + name='max_disk_size', + field=models.IntegerField(default=20, help_text=b'-1 for unlimited. Any integer value', validators=[django.core.validators.MinValueValidator(-1)]), + ), + migrations.AlterField( + model_name='userattributes', + name='max_instances', + field=models.IntegerField(default=1, help_text=b'-1 for unlimited. Any integer value', validators=[django.core.validators.MinValueValidator(-1)]), + ), + migrations.AlterField( + model_name='userattributes', + name='max_memory', + field=models.IntegerField(default=2048, help_text=b'-1 for unlimited. Any integer value', validators=[django.core.validators.MinValueValidator(-1)]), + ), + ] diff --git a/accounts/migrations/0012_auto_20180625_1331.py b/accounts/migrations/0012_auto_20180625_1331.py new file mode 100644 index 0000000..827599e --- /dev/null +++ b/accounts/migrations/0012_auto_20180625_1331.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.13 on 2018-06-25 13:31 +from __future__ import unicode_literals + +import django.core.validators +from django.db import migrations, models +import re + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0011_auto_20180625_1313'), + ] + + operations = [ + migrations.AlterField( + model_name='userattributes', + name='max_cpus', + field=models.IntegerField(default=1, help_text=b'-1 for unlimited. Any integer value', validators=[django.core.validators.RegexValidator(re.compile('^-?\\d+\\Z'), code='invalid', message='Enter a valid integer.')]), + ), + migrations.AlterField( + model_name='userattributes', + name='max_disk_size', + field=models.IntegerField(default=20, help_text=b'-1 for unlimited. Any integer value', validators=[django.core.validators.RegexValidator(re.compile('^-?\\d+\\Z'), code='invalid', message='Enter a valid integer.')]), + ), + migrations.AlterField( + model_name='userattributes', + name='max_instances', + field=models.IntegerField(default=1, help_text=b'-1 for unlimited. Any integer value', validators=[django.core.validators.RegexValidator(re.compile('^-?\\d+\\Z'), code='invalid', message='Enter a valid integer.')]), + ), + migrations.AlterField( + model_name='userattributes', + name='max_memory', + field=models.IntegerField(default=2048, help_text=b'-1 for unlimited. Any integer value', validators=[django.core.validators.RegexValidator(re.compile('^-?\\d+\\Z'), code='invalid', message='Enter a valid integer.')]), + ), + ] diff --git a/accounts/migrations/0013_auto_20180625_1358.py b/accounts/migrations/0013_auto_20180625_1358.py new file mode 100644 index 0000000..1fdec50 --- /dev/null +++ b/accounts/migrations/0013_auto_20180625_1358.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.13 on 2018-06-25 13:58 +from __future__ import unicode_literals + +import django.core.validators +from django.db import migrations, models +import re + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0012_auto_20180625_1331'), + ] + + operations = [ + migrations.AlterField( + model_name='userattributes', + name='max_cpus', + field=models.IntegerField(default=1, help_text=b'-1 for unlimited. Any integer value', validators=[django.core.validators.RegexValidator(re.compile('^-?\\d+\\Z'), code='invalid', message='Enter a valid integer.'), django.core.validators.MinValueValidator(-1)]), + ), + migrations.AlterField( + model_name='userattributes', + name='max_disk_size', + field=models.IntegerField(default=20, help_text=b'-1 for unlimited. Any integer value', validators=[django.core.validators.RegexValidator(re.compile('^-?\\d+\\Z'), code='invalid', message='Enter a valid integer.'), django.core.validators.MinValueValidator(-1)]), + ), + migrations.AlterField( + model_name='userattributes', + name='max_instances', + field=models.IntegerField(default=1, help_text=b'-1 for unlimited. Any integer value', validators=[django.core.validators.RegexValidator(re.compile('^-?\\d+\\Z'), code='invalid', message='Enter a valid integer.'), django.core.validators.MinValueValidator(-1)]), + ), + migrations.AlterField( + model_name='userattributes', + name='max_memory', + field=models.IntegerField(default=2048, help_text=b'-1 for unlimited. Any integer value', validators=[django.core.validators.RegexValidator(re.compile('^-?\\d+\\Z'), code='invalid', message='Enter a valid integer.'), django.core.validators.MinValueValidator(-1)]), + ), + ] diff --git a/accounts/models.py b/accounts/models.py index 19e3a20..3454ef2 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -2,6 +2,7 @@ from django.db import models from django.contrib.auth.models import User from django.conf import settings from instances.models import Instance +from django.core.validators import integer_validator, MinValueValidator class UserInstance(models.Model): @@ -26,10 +27,10 @@ class UserSSHKey(models.Model): class UserAttributes(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) can_clone_instances = models.BooleanField(default=True) - max_instances = models.IntegerField(default=1) - max_cpus = models.IntegerField(default=1) - max_memory = models.IntegerField(default=2048) - max_disk_size = models.IntegerField(default=20) + max_instances = models.IntegerField(default=1, help_text="-1 for unlimited. Any integer value", validators=[integer_validator,MinValueValidator(-1),]) + max_cpus = models.IntegerField(default=1, help_text="-1 for unlimited. Any integer value", validators=[integer_validator,MinValueValidator(-1)]) + max_memory = models.IntegerField(default=2048, help_text="-1 for unlimited. Any integer value", validators=[integer_validator,MinValueValidator(-1)]) + max_disk_size = models.IntegerField(default=20, help_text="-1 for unlimited. Any integer value", validators=[integer_validator,MinValueValidator(-1)]) @staticmethod def create_missing_userattributes(user): diff --git a/accounts/templates/accounts.html b/accounts/templates/accounts.html index 4fdfc8a..d8751ab 100644 --- a/accounts/templates/accounts.html +++ b/accounts/templates/accounts.html @@ -92,25 +92,25 @@
# | Name Description |
Host User |
Status | VCPU | Memory ({% trans "MB" %}) |
- Actions | +Actions & Usage | ||
---|---|---|---|---|---|---|---|---|---|
{{ forloop.counter }} | +{{ host.1 }} | ++ | {% ifequal host.2 1 %}{% trans "Active" %} + {% endifequal %} + {% ifequal host.2 2 %}{% trans "Not Active" %} + {% endifequal %} + {% ifequal host.2 3 %}{% trans "Connection Failed" %} + {% endifequal %} + | +{{ host.3 }} | +{{ host.4|filesizeformat }} | +Mem Usage: {{ host.5 }}% | +|||
{{ vm }} {{ info.title }} |
+ + | {{ forloop.counter }} {{ vm }} {{ info.title }} |
{{ host.1 }} {% if info.userinstances.count > 0 %}{{ info.userinstances.first_user.user.username }}{% if info.userinstances.count > 1 %} (+{{ info.userinstances.count|add:"-1" }}){% endif %}{% endif %} |
{% ifequal info.status 1 %} {% trans "Active" %} @@ -63,8 +82,8 @@ {% trans "Suspend" %} {% endifequal %} | -{{ info.vcpu }} | -{{ info.memory }} | +{{ info.vcpu }} | +{{ info.memory |filesizeformat }} |