Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE3
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
5
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
5c8fa224
authored
Jul 25, 2022
by
Karsa Zoltán István
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
forms
parent
439fc600
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
circle/dashboard/forms.py
+6
-0
circle/vm/models/instance.py
+22
-0
No files found.
circle/dashboard/forms.py
View file @
5c8fa224
...
@@ -1551,6 +1551,12 @@ class CIDataForm(forms.ModelForm):
...
@@ -1551,6 +1551,12 @@ class CIDataForm(forms.ModelForm):
helper
.
form_show_labels
=
False
helper
.
form_show_labels
=
False
return
helper
return
helper
def
clean
(
self
):
cleaned_data
=
super
(
forms
.
ModelForm
,
self
)
.
clean
()
Instance
.
validate_meta_data
(
cleaned_data
[
'ci_meta_data'
])
Instance
.
validate_user_data
(
cleaned_data
[
'ci_user_data'
])
return
cleaned_data
class
GroupPermissionForm
(
forms
.
ModelForm
):
class
GroupPermissionForm
(
forms
.
ModelForm
):
permissions
=
forms
.
ModelMultipleChoiceField
(
permissions
=
forms
.
ModelMultipleChoiceField
(
...
...
circle/vm/models/instance.py
View file @
5c8fa224
...
@@ -38,6 +38,7 @@ from django.utils import timezone
...
@@ -38,6 +38,7 @@ from django.utils import timezone
from
django.utils.translation
import
ugettext_lazy
as
_
,
ugettext_noop
from
django.utils.translation
import
ugettext_lazy
as
_
,
ugettext_noop
from
passlib.hash
import
sha512_crypt
from
passlib.hash
import
sha512_crypt
import
yaml
from
model_utils
import
Choices
from
model_utils
import
Choices
from
model_utils.managers
import
QueryManager
from
model_utils.managers
import
QueryManager
...
@@ -47,6 +48,7 @@ from taggit.managers import TaggableManager
...
@@ -47,6 +48,7 @@ from taggit.managers import TaggableManager
from
django.db
import
models
from
django.db
import
models
from
acl.models
import
AclBase
from
acl.models
import
AclBase
from
django
import
forms
from
common.models
import
(
from
common.models
import
(
activitycontextimpl
,
create_readable
,
HumanReadableException
,
activitycontextimpl
,
create_readable
,
HumanReadableException
,
)
)
...
@@ -370,11 +372,31 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
...
@@ -370,11 +372,31 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
data
=
data
.
replace
(
'{{password}}'
,
passwd
)
data
=
data
.
replace
(
'{{password}}'
,
passwd
)
return
data
return
data
@classmethod
def
validate_user_data
(
cls
,
user_data
):
data
=
user_data
.
replace
(
'{{user}}'
,
'user'
)
data
=
data
.
replace
(
'{{password}}'
,
'passwd'
)
try
:
yaml
.
dump
(
yaml
.
load
(
data
,
Loader
=
yaml
.
Loader
))
except
yaml
.
YAMLError
as
exc
:
raise
forms
.
ValidationError
(
exc
.
problem_mark
)
return
True
@property
@property
def
get_meta_data
(
self
):
def
get_meta_data
(
self
):
data
=
str
(
self
.
ci_meta_data
)
.
replace
(
'{{hostname}}'
,
self
.
short_hostname
)
data
=
str
(
self
.
ci_meta_data
)
.
replace
(
'{{hostname}}'
,
self
.
short_hostname
)
return
data
return
data
@classmethod
def
validate_meta_data
(
cls
,
meta_data
):
data
=
meta_data
.
replace
(
'{{hostname}}'
,
'hostname'
)
try
:
yaml
.
dump
(
yaml
.
load
(
data
,
Loader
=
yaml
.
Loader
))
except
yaml
.
YAMLError
as
exc
:
raise
forms
.
ValidationError
(
exc
.
problem_mark
)
return
True
def
_update_status
(
self
):
def
_update_status
(
self
):
"""Set the proper status of the instance to Instance.status.
"""Set the proper status of the instance to Instance.status.
"""
"""
...
...
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