Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c53db327
authored
4 years ago
by
Szeberényi Imre
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'group_instance_limits' into 'master'
Group instance limits See merge request
!421
parents
9413d8af
133e6649
Pipeline
#1389
failed with stage
in 0 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
5 deletions
+49
-5
circle/dashboard/forms.py
+4
-1
circle/dashboard/migrations/0009_auto_20210201_1730.py
+25
-0
circle/dashboard/models.py
+2
-0
circle/dashboard/views/vm.py
+18
-4
No files found.
circle/dashboard/forms.py
View file @
c53db327
...
@@ -271,6 +271,8 @@ class GroupProfileUpdateForm(NoFormTagMixin, forms.ModelForm):
...
@@ -271,6 +271,8 @@ class GroupProfileUpdateForm(NoFormTagMixin, forms.ModelForm):
if
not
new_groups
:
if
not
new_groups
:
self
.
fields
[
'org_id'
]
.
widget
=
HiddenInput
()
self
.
fields
[
'org_id'
]
.
widget
=
HiddenInput
()
self
.
fields
[
'disk_quota'
]
.
widget
=
HiddenInput
()
self
.
fields
[
'disk_quota'
]
.
widget
=
HiddenInput
()
self
.
fields
[
'instance_limit'
]
.
widget
=
HiddenInput
()
self
.
fields
[
'template_instance_limit'
]
.
widget
=
HiddenInput
()
self
.
fields
[
'description'
]
.
widget
=
forms
.
Textarea
(
attrs
=
{
'rows'
:
3
})
self
.
fields
[
'description'
]
.
widget
=
forms
.
Textarea
(
attrs
=
{
'rows'
:
3
})
@property
@property
...
@@ -288,7 +290,8 @@ class GroupProfileUpdateForm(NoFormTagMixin, forms.ModelForm):
...
@@ -288,7 +290,8 @@ class GroupProfileUpdateForm(NoFormTagMixin, forms.ModelForm):
class
Meta
:
class
Meta
:
model
=
GroupProfile
model
=
GroupProfile
fields
=
(
'description'
,
'org_id'
,
'disk_quota'
)
fields
=
(
'description'
,
'org_id'
,
'disk_quota'
,
'instance_limit'
,
'template_instance_limit'
)
class
HostForm
(
NoFormTagMixin
,
forms
.
ModelForm
):
class
HostForm
(
NoFormTagMixin
,
forms
.
ModelForm
):
...
...
This diff is collapsed.
Click to expand it.
circle/dashboard/migrations/0009_auto_20210201_1730.py
0 → 100644
View file @
c53db327
# -*- coding: utf-8 -*-
# Generated by Django 1.11.25 on 2021-02-01 17:30
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'dashboard'
,
'0008_profile_template_instance_limit'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'groupprofile'
,
name
=
'instance_limit'
,
field
=
models
.
IntegerField
(
default
=
5
),
),
migrations
.
AddField
(
model_name
=
'groupprofile'
,
name
=
'template_instance_limit'
,
field
=
models
.
IntegerField
(
default
=
1
),
),
]
This diff is collapsed.
Click to expand it.
circle/dashboard/models.py
View file @
c53db327
...
@@ -293,6 +293,8 @@ class GroupProfile(AclBase):
...
@@ -293,6 +293,8 @@ class GroupProfile(AclBase):
org_id
=
CharField
(
org_id
=
CharField
(
unique
=
True
,
blank
=
True
,
null
=
True
,
max_length
=
64
,
unique
=
True
,
blank
=
True
,
null
=
True
,
max_length
=
64
,
help_text
=
_
(
'Unique identifier of the group at the organization.'
))
help_text
=
_
(
'Unique identifier of the group at the organization.'
))
instance_limit
=
IntegerField
(
default
=
5
)
template_instance_limit
=
IntegerField
(
default
=
1
)
description
=
TextField
(
blank
=
True
)
description
=
TextField
(
blank
=
True
)
disk_quota
=
FileSizeField
(
disk_quota
=
FileSizeField
(
verbose_name
=
_
(
'disk quota'
),
verbose_name
=
_
(
'disk quota'
),
...
...
This diff is collapsed.
Click to expand it.
circle/dashboard/views/vm.py
View file @
c53db327
...
@@ -1035,8 +1035,10 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
...
@@ -1035,8 +1035,10 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
except
ValueError
:
except
ValueError
:
messages
.
error
(
self
.
request
,
_
(
"Error during filtering."
))
messages
.
error
(
self
.
request
,
_
(
"Error during filtering."
))
return
queryset
.
prefetch_related
(
"owner"
,
"node"
,
"owner__profile"
,
"lease"
,
return
queryset
.
prefetch_related
(
"interface_set"
,
"interface_set__host"
,
"template"
)
.
distinct
()
"owner"
,
"node"
,
"owner__profile"
,
"lease"
,
"interface_set"
,
"interface_set__host"
,
"template"
)
.
distinct
()
class
VmCreate
(
LoginRequiredMixin
,
TemplateView
):
class
VmCreate
(
LoginRequiredMixin
,
TemplateView
):
...
@@ -1170,8 +1172,20 @@ class VmCreate(LoginRequiredMixin, TemplateView):
...
@@ -1170,8 +1172,20 @@ class VmCreate(LoginRequiredMixin, TemplateView):
# limit chekcs
# limit chekcs
try
:
try
:
instance_limit
=
user
.
profile
.
instance_limit
instance_limits
=
[
user
.
profile
.
instance_limit
]
template_instance_limit
=
user
.
profile
.
template_instance_limit
instance_limits
+=
[
group
.
profile
.
instance_limit
for
group
in
user
.
groups
.
all
()
]
template_instance_limits
=
[
user
.
profile
.
template_instance_limit
]
template_instance_limits
+=
[
group
.
profile
.
template_instance_limit
for
group
in
user
.
groups
.
all
()
]
instance_limit
=
max
(
instance_limits
)
template_instance_limit
=
max
(
template_instance_limits
)
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
debug
(
'No profile or instance limit:
%
s'
,
e
)
logger
.
debug
(
'No profile or instance limit:
%
s'
,
e
)
else
:
else
:
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment