Commit cbdce68f by Máhonfai Bálint

Also check group limits when creating VMs

parent f2d34c8e
......@@ -1035,8 +1035,10 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
except ValueError:
messages.error(self.request, _("Error during filtering."))
return queryset.prefetch_related("owner", "node", "owner__profile", "lease",
"interface_set", "interface_set__host", "template").distinct()
return queryset.prefetch_related(
"owner", "node", "owner__profile", "lease",
"interface_set", "interface_set__host", "template"
class VmCreate(LoginRequiredMixin, TemplateView):
......@@ -1170,8 +1172,20 @@ class VmCreate(LoginRequiredMixin, TemplateView):
# limit chekcs
instance_limit = user.profile.instance_limit
template_instance_limit = user.profile.template_instance_limit
instance_limits = [user.profile.instance_limit]
instance_limits += [
for group in user.groups.all()
template_instance_limits = [user.profile.template_instance_limit]
template_instance_limits += [
for group in user.groups.all()
instance_limit = max(instance_limits)
template_instance_limit = max(template_instance_limits)
except Exception as e:
logger.debug('No profile or instance limit: %s', e)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment