Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9f60b684
authored
Mar 09, 2014
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: refactor and comment state property
parent
043a8ccf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
circle/vm/models/instance.py
+11
-5
No files found.
circle/vm/models/instance.py
View file @
9f60b684
...
@@ -276,17 +276,23 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -276,17 +276,23 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
def
state
(
self
):
def
state
(
self
):
"""State of the virtual machine instance.
"""State of the virtual machine instance.
"""
"""
# check special cases
if
self
.
activity_log
.
filter
(
activity_code__endswith
=
'migrate'
,
if
self
.
activity_log
.
filter
(
activity_code__endswith
=
'migrate'
,
finished__isnull
=
True
)
.
exists
():
finished__isnull
=
True
)
.
exists
():
return
'MIGRATING'
return
'MIGRATING'
# <<< add checks for special cases before this
# default case
acts
=
self
.
activity_log
.
filter
(
finished__isnull
=
False
,
resultant_state__isnull
=
False
)
.
order_by
(
'-finished'
)[:
1
]
try
:
try
:
act
=
self
.
activity_log
.
filter
(
finished__isnull
=
False
,
act
=
acts
[
0
]
resultant_state__isnull
=
False
)
.
order_by
(
'-finished'
)
.
all
()[
0
]
except
IndexError
:
except
IndexError
:
act
=
None
return
'NOSTATE'
return
'NOSTATE'
if
act
is
None
else
act
.
resultant_state
else
:
return
act
.
resultant_state
def
is_console_available
(
self
):
def
is_console_available
(
self
):
return
self
.
state
in
(
'RUNNING'
,
)
return
self
.
state
in
(
'RUNNING'
,
)
...
...
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