1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-24 23:25:24 +00:00

Merge pull request #484 from catborise/master

updates & fixes 1
This commit is contained in:
catborise 2022-01-12 13:41:10 +03:00 committed by GitHub
commit 9977c650db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 15412 additions and 15050 deletions

View file

@ -1,4 +1,4 @@
FROM phusion/baseimage:focal-1.0.0 FROM phusion/baseimage:focal-1.1.0
EXPOSE 80 EXPOSE 80
EXPOSE 6080 EXPOSE 6080

View file

@ -32,7 +32,7 @@ WebVirtCloud is a virtualization web interface for admins and users. It can dele
## Quick Install with Installer (Beta) ## Quick Install with Installer (Beta)
Install an OS and run specified commands. Installer supported OSes: Ubuntu 18.04, Debian 10, Centos/OEL/RHEL 8. Install an OS and run specified commands. Installer supported OSes: Ubuntu 18.04/20.04, Debian 10/11, Centos/OEL/RHEL 8.
It can be installed on a virtual machine, physical host or on a KVM host. It can be installed on a virtual machine, physical host or on a KVM host.
```bash ```bash

View file

@ -1,4 +1,4 @@
Django==3.2.10 Django==3.2.11
django_bootstrap5==21.2 django_bootstrap5==21.2
django-icons==21.1 django-icons==21.1
django-login-required-middleware==0.7 django-login-required-middleware==0.7

View file

@ -4,4 +4,4 @@ django-debug-toolbar==3.2.4
pycodestyle==2.8.0 pycodestyle==2.8.0
pyflakes==2.4.0 pyflakes==2.4.0
pylint==2.12.2 pylint==2.12.2
yapf==0.31.0 yapf==0.32.0

View file

@ -342,15 +342,17 @@ def migrate(request, pk):
compress = request.POST.get("compress", False) compress = request.POST.get("compress", False)
postcopy = request.POST.get("postcopy", False) postcopy = request.POST.get("postcopy", False)
new_compute = Compute.objects.get(id=compute_id) current_host = instance.compute.hostname
target_host = Compute.objects.get(id=compute_id)
try: try:
utils.migrate_instance(new_compute, instance, request.user, live, unsafe, xml_del, offline) utils.migrate_instance(target_host, instance, request.user, live, unsafe, xml_del, offline)
except libvirtError as err: except libvirtError as err:
messages.error(request, err) messages.error(request, err)
msg = _("Instance is migrated to %(hostname)s") % {"hostname": new_compute.hostname} migration_method = "live" if live is True else "offline"
addlogmsg(request.user.username, instance.compute.hostname, instance.name, msg) msg = _("Instance is migrated(%(method)s) to %(hostname)s") % {"hostname": target_host.hostname, "method": migration_method}
addlogmsg(request.user.username, current_host, instance.name, msg)
return redirect(request.META.get("HTTP_REFERER")) return redirect(request.META.get("HTTP_REFERER"))

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -12,14 +12,13 @@ try:
class LdapAuthenticationBackend(ModelBackend): class LdapAuthenticationBackend(ModelBackend):
def get_LDAP_user(self, username, password, filterString): def get_LDAP_user(self, username, password, filterString):
print('get_LDAP_user') print('get_LDAP_user {}'.format(username))
try: try:
server = Server(settings.LDAP_URL, port=settings.LDAP_PORT, server = Server(settings.LDAP_URL, port=settings.LDAP_PORT,
use_ssl=settings.USE_SSL,get_info=ALL) use_ssl=settings.USE_SSL,get_info=ALL)
connection = Connection(server, connection = Connection(server,
settings.LDAP_MASTER_DN, settings.LDAP_MASTER_DN,
settings.LDAP_MASTER_PW, auto_bind=True) settings.LDAP_MASTER_PW, auto_bind=True)
connection.search(settings.LDAP_ROOT_DN, connection.search(settings.LDAP_ROOT_DN,
'(&({attr}={login})({filter}))'.format( '(&({attr}={login})({filter}))'.format(
attr=settings.LDAP_USER_UID_PREFIX, attr=settings.LDAP_USER_UID_PREFIX,
@ -31,11 +30,10 @@ try:
return None return None
specificUser = connection.response[0] specificUser = connection.response[0]
userDn = str(specificUser.get('raw_dn'),'utf-8') userDn = str(specificUser.get('raw_dn'),'utf-8')
with Connection(server, with Connection(server, userDn, password) as con:
userDn,
password) as con:
return username return username
except: except Exception as e:
print("LDAP Exception: {}".format(e))
return None return None
return None return None
@ -50,6 +48,7 @@ try:
if self.get_LDAP_user(username, password, settings.LDAP_SEARCH_GROUP_FILTER_ADMINS) is None: if self.get_LDAP_user(username, password, settings.LDAP_SEARCH_GROUP_FILTER_ADMINS) is None:
if self.get_LDAP_user(username, password, settings.LDAP_SEARCH_GROUP_FILTER_STAFF) is None: if self.get_LDAP_user(username, password, settings.LDAP_SEARCH_GROUP_FILTER_STAFF) is None:
if self.get_LDAP_user(username, password, settings.LDAP_SEARCH_GROUP_FILTER_USERS) is None: if self.get_LDAP_user(username, password, settings.LDAP_SEARCH_GROUP_FILTER_USERS) is None:
print("User does not belong to any search group. Check LDAP_SEARCH_GROUP_FILTER in settings.")
return None return None
else: else:
isStaff = True isStaff = True
@ -62,7 +61,7 @@ try:
attributes = UserAttributes.objects.get(user=user) attributes = UserAttributes.objects.get(user=user)
# TODO VERIFY # TODO VERIFY
except User.DoesNotExist: except User.DoesNotExist:
print("authenticate-create new user") print("authenticate-create new user: {}".format(username))
user = User(username=username) user = User(username=username)
user.is_active = True user.is_active = True
user.is_staff = isStaff user.is_staff = isStaff

View file

@ -268,6 +268,7 @@ LDAP_MASTER_PW = ''
LDAP_ROOT_DN = '' LDAP_ROOT_DN = ''
## Queries to identify the users, i use groupOfUniqueNames on openldap ## Queries to identify the users, i use groupOfUniqueNames on openldap
### PLEASE BE SURE memberOf overlay is activated on slapd
## e.g. memberOf=cn=admins,cn=staff,cn=webvirtcloud,ou=groups,dc=kendar,dc=org ## e.g. memberOf=cn=admins,cn=staff,cn=webvirtcloud,ou=groups,dc=kendar,dc=org
LDAP_SEARCH_GROUP_FILTER_ADMINS = '' LDAP_SEARCH_GROUP_FILTER_ADMINS = ''
## e.g. memberOf=cn=staff,cn=webvirtcloud,ou=groups,dc=kendar,dc=org ## e.g. memberOf=cn=staff,cn=webvirtcloud,ou=groups,dc=kendar,dc=org