diff --git a/README.md b/README.md index a829d15..f917721 100644 --- a/README.md +++ b/README.md @@ -397,11 +397,21 @@ sudo sed -i "s/LDAP_URL = ''/LDAP_URL = 'myldap.server.com'/g"" /srv/webvirtclou sudo sed -i "s/LDAP_ROOT_DN = ''/LDAP_ROOT_DN = 'dc=server,dc=com'/g"" /srv/webvirtcloud/webvirtcloud/settings.py ``` -Set the user that has browse access to LDAP and its password +Set the passphrase to decrypt the password +```bash +sudo sed -i "s/pass:MYPASSPHRASE/pass:MYTRUEPASSPHRASE/g" /srv/webvirtcloud/webvirtcloud/.dec_ldap_pwd.sh +``` + +Encrypt the password +```bash +echo MYPASSWORD | openssl enc -pbkdf2 -salt -pass pass:MYTRUEPASSPHRASE | base64 +``` + +Set the user that has browse access to LDAP and its password encrypted ```bash sudo sed -i "s/LDAP_MASTER_DN = ''/LDAP_MASTER_DN = 'cn=admin,ou=users,dc=kendar,dc=org'/g"" /srv/webvirtcloud/webvirtcloud/settings.py -sudo sed -i "s/LDAP_MASTER_PW = ''/LDAP_MASTER_PW = 'password'/g"" /srv/webvirtcloud/webvirtcloud/settings.py +sudo sed -i "s/LDAP_MASTER_PW_ENC = ''/LDAP_MASTER_PW_ENC = 'MYPASSWORDENCRYPTED'/g"" /srv/webvirtcloud/webvirtcloud/settings.py ``` Set the attribute that will be used to find the username, i usually use the cn diff --git a/admin/migrations/0003_create_group_technicians.py b/admin/migrations/0003_create_group_technicians.py new file mode 100644 index 0000000..d5b1cae --- /dev/null +++ b/admin/migrations/0003_create_group_technicians.py @@ -0,0 +1,15 @@ +from django.db import models, migrations + +def apply_migration(apps, schema_editor): + Group = apps.get_model('auth', 'Group') + Group.objects.create(name='Technicians') + +class Migration(migrations.Migration): + + dependencies = [ + ('admin', '0002_auto_20200609_0830'), + ] + + operations = [ + migrations.RunPython(apply_migration) + ] diff --git a/console/views.py b/console/views.py index 7a6691b..81f5465 100644 --- a/console/views.py +++ b/console/views.py @@ -41,7 +41,7 @@ def console(request): host = int(temptoken[0]) uuid = temptoken[1] - if not request.user.is_superuser: + if not request.user.is_superuser and not request.user.has_perm("instances.view_instances"): try: userInstance = UserInstance.objects.get( instance__compute_id=host, instance__uuid=uuid, user__id=request.user.id diff --git a/instances/models.py b/instances/models.py index 68d2ecc..147b099 100644 --- a/instances/models.py +++ b/instances/models.py @@ -28,6 +28,7 @@ class Instance(models.Model): uuid = models.CharField(_('uuid'), max_length=36, db_index=True) is_template = models.BooleanField(_('is template'), default=False) created = models.DateTimeField(_('created'), auto_now_add=True) + drbd = models.CharField(_('drbd'), max_length=24, default="None") objects = InstanceManager() @@ -214,6 +215,8 @@ class PermissionSet(models.Model): permissions = [ ('clone_instances', 'Can clone instances'), ('passwordless_console', _('Can access console without password')), + ('view_instances', 'Can view instances'), + ('snapshot_instances', 'Can snapshot instances'), ] managed = False diff --git a/instances/templates/allinstances.html b/instances/templates/allinstances.html index e69bc22..095d99c 100644 --- a/instances/templates/allinstances.html +++ b/instances/templates/allinstances.html @@ -25,7 +25,7 @@ {% endif %} {% endfor %}
- {% if app_settings.VIEW_INSTANCES_LIST_STYLE == 'grouped' and request.user.is_superuser %} + {% if app_settings.VIEW_INSTANCES_LIST_STYLE == 'grouped' and request.user.is_superuser or 'instances.view_instances' in perms %} {% include 'allinstances_index_grouped.html' %} {% else %} {% include 'allinstances_index_nongrouped.html' %} diff --git a/instances/templates/allinstances_index_grouped.html b/instances/templates/allinstances_index_grouped.html index ef5e119..a6c3bc6 100644 --- a/instances/templates/allinstances_index_grouped.html +++ b/instances/templates/allinstances_index_grouped.html @@ -7,6 +7,7 @@ {% trans "Name" %}
{% trans "Description" %} {% trans "User"%} {% trans "Status" %} + {% trans "Role/Disk" %} {% trans "VCPU" %} {% trans "Memory" %} {% trans "Actions" %} & {% trans "Mem Usage" %} @@ -27,6 +28,7 @@ {% trans "Connected" %} + {{ compute.cpu_count }} {{ compute.ram_size|filesizeformat }} @@ -62,6 +64,9 @@ {% trans "Suspended" %} {% endif %} + + {% if instance.drbd == "Primary/OK" or instance.drbd == "Secondary/OK" %}{% else %}{% endif %}{{ instance.drbd }} + {{ instance.proxy.instance.info.3 }} {{ instance.cur_memory }} MB diff --git a/instances/templates/allinstances_index_nongrouped.html b/instances/templates/allinstances_index_nongrouped.html index e32e29d..114b6b8 100644 --- a/instances/templates/allinstances_index_nongrouped.html +++ b/instances/templates/allinstances_index_nongrouped.html @@ -7,6 +7,7 @@ {% trans 'Host' %}
{% trans 'User' %} {% endif %} {% trans 'Status' %} + {% trans 'Role/Disk' %} {% trans 'VCPU' %} {% trans 'Memory' %} {% trans 'Actions' %} @@ -44,6 +45,9 @@ {% if instance.proxy.instance.info.0 == 3 %}{% trans "Suspended" %}{% endif %} + + {% if instance.drbd == "Primary/OK" or instance.drbd == "Secondary/OK" %}{% else %}{% endif %}{{ instance.drbd }} + {{ instance.proxy.instance.info.3 }} {{ instance.cur_memory }} MB diff --git a/instances/templates/instance.html b/instances/templates/instance.html index a1b88b4..cb18556 100644 --- a/instances/templates/instance.html +++ b/instances/templates/instance.html @@ -93,7 +93,7 @@ {% trans "Resize" %} - {% if allow_admin_or_not_template %} + {% if allow_admin_or_not_template and 'instances.snapshot_instances' in perms %}