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/.travis.yml b/.travis.yml index aa532e7..cbe3e6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,9 @@ language: python python: - "2.7" env: - - DJANGO=1.8 + - DJANGO=1.11.14 install: - - pip install -r dev/requirements.txt --use-mirrors + - pip install -r dev/requirements.txt script: - pep8 --exclude=IPy.py --ignore=E501 vrtManager accounts computes \ console create instances interfaces \ diff --git a/Dockerfile b/Dockerfile index 3bfae3c..3ed8af4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ RUN echo 'APT::Get::Clean=always;' >> /etc/apt/apt.conf.d/99AutomaticClean RUN apt-get update -qqy RUN DEBIAN_FRONTEND=noninteractive apt-get -qyy install \ -o APT::Install-Suggests=false \ - git python-virtualenv python-dev libxml2-dev libvirt-dev zlib1g-dev nginx libsasl2-modules + git python-virtualenv python-dev python-lxml libvirt-dev zlib1g-dev nginx libsasl2-modules ADD . /srv/webvirtcloud RUN chown -R www-data:www-data /srv/webvirtcloud diff --git a/README.md b/README.md index cd5c4e5..cb68cc2 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 python-guestfs git clone https://github.com/retspen/webvirtcloud cd webvirtcloud cp webvirtcloud/settings.py.template webvirtcloud/settings.py @@ -67,7 +67,7 @@ wget -O - https://clck.ru/9V9fH | sudo sh ### Install WebVirtCloud panel (CentOS) ```bash -sudo yum -y install python-virtualenv python-devel libvirt-devel glibc gcc nginx supervisor libxml2 libxml2-devel git +sudo yum -y install python-virtualenv python-devel libvirt-devel glibc gcc nginx supervisor python-lxml git python-libguestfs ``` #### Creating directories and cloning repo @@ -230,7 +230,10 @@ datasource: ### How To Update ```bash +sudo virtualenv venv +sudo source venv/bin/activate git pull +pip install -U -r conf/requirements.txt python manage.py migrate sudo service supervisor restart ``` diff --git a/Vagrantfile b/Vagrantfile index 539468d..a92a1ab 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -10,7 +10,7 @@ Vagrant.configure(2) do |config| sudo sed -i 's/auth_tcp = \"sasl\"/auth_tcp = \"none\"/g' /etc/libvirt/libvirtd.conf sudo service libvirt-bin restart sudo adduser vagrant libvirtd - sudo apt-get -y install python-virtualenv python-dev libxml2-dev libvirt-dev zlib1g-dev + sudo apt-get -y install python-virtualenv python-dev python-lxml libvirt-dev zlib1g-dev virtualenv /vagrant/venv source /vagrant/venv/bin/activate pip install -r /vagrant/dev/requirements.txt 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 |
+ User | Status | VCPU | -Memory ({% trans "MB" %}) |
- Actions | +Memory | +Actions & Mem 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 }} | ++ | + +||||
{{ 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 %} |
+ + | {{ forloop.counter }} {{ vm }} {{ info.title }} |
+ {% 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" %} {% endifequal %} @@ -63,8 +83,8 @@ {% trans "Suspend" %} {% endifequal %} | -{{ info.vcpu }} | -{{ info.memory }} | +{{ info.vcpu }} | +{{ info.memory |filesizeformat }} |