Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
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
Commit
d4a34912
authored
Sep 27, 2013
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage, vm: add missing *Activity model helper methods
parent
0a32ce30
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
circle/storage/models.py
+12
-0
circle/vm/models.py
+11
-0
No files found.
circle/storage/models.py
View file @
d4a34912
...
...
@@ -6,6 +6,7 @@ import uuid
from
django.contrib.auth.models
import
User
from
django.db.models
import
(
Model
,
BooleanField
,
CharField
,
DateTimeField
,
ForeignKey
,
TextField
)
from
django.utils
import
timezone
from
django.utils.translation
import
ugettext_lazy
as
_
from
model_utils.models
import
TimeStampedModel
from
sizefield.models
import
FileSizeField
...
...
@@ -172,3 +173,14 @@ class DiskActivity(TimeStampedModel):
result
=
TextField
(
verbose_name
=
_
(
'result'
),
blank
=
True
,
null
=
True
)
state
=
CharField
(
verbose_name
=
_
(
'state'
),
default
=
'PENDING'
,
max_length
=
50
)
def
update_state
(
self
,
new_state
):
self
.
state
=
new_state
self
.
save
()
def
finish
(
self
,
result
=
None
):
if
not
self
.
finished
:
self
.
finished
=
timezone
.
now
()
self
.
result
=
result
self
.
state
=
'COMPLETED'
self
.
save
()
circle/vm/models.py
View file @
d4a34912
...
...
@@ -121,6 +121,17 @@ class NodeActivity(TimeStampedModel):
status
=
CharField
(
verbose_name
=
_
(
'status'
),
default
=
'PENDING'
,
max_length
=
50
,
help_text
=
_
(
'Actual state of activity'
))
def
update_state
(
self
,
new_state
):
self
.
state
=
new_state
self
.
save
()
def
finish
(
self
,
result
=
None
):
if
not
self
.
finished
:
self
.
finished
=
timezone
.
now
()
self
.
result
=
result
self
.
state
=
'COMPLETED'
self
.
save
()
class
Lease
(
Model
):
...
...
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