diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml
index 79354b3..bcf66c1 100644
--- a/.github/workflows/linter.yml
+++ b/.github/workflows/linter.yml
@@ -6,7 +6,7 @@ name: linter
# events but only for the master branch
on:
push:
- branches: [ master ]
+ branches: [ '*' ]
pull_request:
branches: [ master ]
diff --git a/README.md b/README.md
index 2e7581f..b7e7640 100644
--- a/README.md
+++ b/README.md
@@ -316,6 +316,23 @@ pip3 install -U -r conf/requirements.txt
python3 manage.py migrate
sudo service supervisor restart
```
+
+### Running tests
+Server on which tests will be performed must have libvirt up and running.
+It must not contain vms.
+It must have `default` storage which not contain any disk images.
+It must have `default` network which must be on.
+Setup venv
+```bash
+python -m venv venv
+source venv/bin/activate
+pip install -r conf/requirements.txt
+```
+Run tests
+```bash
+python menage.py test
+```
+
### Screenshots
Instance Detail:
diff --git a/accounts/models.py b/accounts/models.py
index 072d9f2..1369158 100644
--- a/accounts/models.py
+++ b/accounts/models.py
@@ -6,6 +6,9 @@ from django.utils.translation import ugettext_lazy as _
from instances.models import Instance
+class UserInstanceManager(models.Manager):
+ def get_queryset(self):
+ return super().get_queryset().select_related('instance', 'user')
class UserInstance(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
@@ -14,6 +17,8 @@ class UserInstance(models.Model):
is_delete = models.BooleanField(default=False)
is_vnc = models.BooleanField(default=False)
+ objects = UserInstanceManager()
+
def __str__(self):
return _('Instance "%(inst)s" of user %(user)s') % {'inst': self.instance, 'user': self.user}
diff --git a/accounts/templates/account.html b/accounts/templates/account.html
index 13d8f69..abf8da3 100644
--- a/accounts/templates/account.html
+++ b/accounts/templates/account.html
@@ -42,7 +42,7 @@
{% for inst in user_insts %}
| {% trans 'Name' %} {% trans 'Description' %} |
+ {% trans 'User' %} | +{% trans 'Status' %} | +{% trans 'VCPU' %} | +{% trans 'Memory' %} | +{% trans 'Actions' %} | +
|---|---|---|---|---|---|
| + + {{ instance.name }} + + | ++ + {% if instance.userinstance_set.all.count > 0 %} + {{ instance.userinstance_set.all.0.user }} + {% if instance.userinstance_set.all.count > 1 %} + (+{{ instance.userinstance_set.all.count|add:"-1" }}) + {% endif %} + {% endif %} + + | ++ {% if instance.proxy.instance.info.0 == 1 %}{% trans "Active" %}{% endif %} + {% if instance.proxy.instance.info.0 == 5 %}{% trans "Off" %}{% endif %} + {% if instance.proxy.instance.info.0 == 3 %}{% trans "Suspended" %}{% endif %} + | +{{ instance.proxy.instance.info.3 }} | +{% widthratio instance.proxy.instance.info.1 1024 1 %} MiB | ++ {% include 'instance_actions.html' %} + | +
{% trans "Volume parameters" %}
{% trans "Volume parameters" %}
| {% trans 'Name' %} | -{% trans 'Status' %} | -{% trans 'VCPU' %} | -{% trans 'Memory' %} | -{% trans 'Actions' %} | -
|---|---|---|---|---|
| {{ vm.name }} {{ vm.title }} |
- {% if vm.status == 1 %} - {% trans "Active" %} - {% endif %} - {% if vm.status == 5 %} - {% trans "Off" %} - {% endif %} - {% if vm.status == 3 %} - {% trans "Suspend" %} - {% endif %} - | -{{ vm.vcpu }} | -{{ vm.memory }} {% trans "MB" %} | -- {% include "instance_actions.html" %} - | -
| # | -{% trans "Name" %} {% trans "Description" %} |
- {% trans "User"%} | -{% trans "Status" %} | -{% trans "VCPU" %} | -{% trans "Memory" %} | -{% trans "Actions" %} & {% trans "Mem Usage" %} | -
|---|---|---|---|---|---|---|
| # | +{% trans "Name" %} {% trans "Description" %} |
+ {% trans "User"%} | +{% trans "Status" %} | +{% trans "VCPU" %} | +{% trans "Memory" %} | +{% trans "Actions" %} & {% trans "Mem Usage" %} | +
| - - | -- {{ host.1 }} - {{ insts.items|length }} - | -- | - {% if host.2 == 1 %}{% trans "Active" %}{% endif %} - {% if host.2 == 2 %}{% trans "Not Active" %}{% endif %} - {% if host.2 == 3 %}{% trans "Connection Failed" %}{% endif %} - | -{{ host.3 }} | -{{ host.4|filesizeformat }} | -
-
-
-
- |
-
| {{ forloop.counter }} | -
- {{ inst }} - {{ vm.title }} - |
- - - {% if vm.userinstances.count > 0 %} {{ vm.userinstances.first_user.user.username }} - {% if vm.userinstances.count > 1 %} (+{{ vm.userinstances.count|add:"-1" }}){% endif %} - {% endif %} - - | -- {% if vm.status == 1 %}{% trans "Active" %}{% endif %} - {% if vm.status == 5 %}{% trans "Off" %}{% endif %} - {% if vm.status == 3 %}{% trans "Suspend" %}{% endif %} - | -{{ vm.vcpu }} | -{{ vm.memory |filesizeformat }} | -- {% include 'instance_actions.html' %} - | -
| + + | ++ {{ compute.name }} + {{ compute.instance_set.count }} + | ++ | + {% trans "Connected" %} + | +{{ compute.cpu_count }} | +{{ compute.ram_size|filesizeformat }} | +
+
+
+
+ |
+
| {{ forloop.counter }} | +
+ {{ instance.name }} + |
+ + + {% if instance.userinstance_set.all.count > 0 %} + {{ instance.userinstance_set.all.0.user }} + {% if instance.userinstance_set.all.count > 1 %} + (+{{ instance.userinstance_set.all.count|add:"-1" }}) + {% endif %} + {% endif %} + + | ++ {% if instance.proxy.instance.info.0 == 1 %}{% trans "Active" %}{% endif %} + {% if instance.proxy.instance.info.0 == 5 %}{% trans "Off" %}{% endif %} + {% if instance.proxy.instance.info.0 == 3 %} + {% trans "Suspended" %} + {% endif %} + | +{{ instance.proxy.instance.info.3 }} | +{{ instance.cur_memory }} MB | ++ {% include 'instance_actions.html' %} + | +
| # | @@ -286,10 +287,10 @@
- |
@@ -872,7 +873,7 @@
{% endif %}
diff --git a/instances/templates/edit_instance_volume.html b/instances/templates/edit_instance_volume.html
index b083b22..ec0c3df 100644
--- a/instances/templates/edit_instance_volume.html
+++ b/instances/templates/edit_instance_volume.html
@@ -52,7 +52,7 @@
|---|