Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
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
1067a9ec
authored
Feb 06, 2014
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: derive instance state from activity log
parent
b478ebb0
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
circle/vm/migrations/0016_del_field_instance_state.py
+0
-0
circle/vm/models/instance.py
+13
-11
No files found.
circle/vm/migrations/0016_del_field_instance_state.py
0 → 100644
View file @
1067a9ec
This diff is collapsed.
Click to expand it.
circle/vm/models/instance.py
View file @
1067a9ec
...
@@ -166,14 +166,6 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -166,14 +166,6 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
* base resource configuration values
* base resource configuration values
* owner and privilege information
* owner and privilege information
"""
"""
STATES
=
[(
'NOSTATE'
,
_
(
'nostate'
)),
(
'RUNNING'
,
_
(
'running'
)),
(
'BLOCKED'
,
_
(
'blocked'
)),
(
'PAUSED'
,
_
(
'paused'
)),
(
'SHUTDOWN'
,
_
(
'shutdown'
)),
(
'SHUTOFF'
,
_
(
'shutoff'
)),
(
'CRASHED'
,
_
(
'crashed'
)),
(
'PMSUSPENDED'
,
_
(
'pmsuspended'
))]
# libvirt domain states
ACL_LEVELS
=
(
ACL_LEVELS
=
(
(
'user'
,
_
(
'user'
)),
# see all details
(
'user'
,
_
(
'user'
)),
# see all details
(
'operator'
,
_
(
'operator'
)),
# console, networking, change state
(
'operator'
,
_
(
'operator'
)),
# console, networking, change state
...
@@ -204,7 +196,6 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -204,7 +196,6 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
related_name
=
'instance_set'
,
related_name
=
'instance_set'
,
help_text
=
_
(
"Current hypervisor of this instance."
),
help_text
=
_
(
"Current hypervisor of this instance."
),
verbose_name
=
_
(
'host node'
))
verbose_name
=
_
(
'host node'
))
state
=
CharField
(
choices
=
STATES
,
default
=
'NOSTATE'
,
max_length
=
20
)
disks
=
ManyToManyField
(
Disk
,
related_name
=
'instance_set'
,
disks
=
ManyToManyField
(
Disk
,
related_name
=
'instance_set'
,
help_text
=
_
(
"Set of mounted disks."
),
help_text
=
_
(
"Set of mounted disks."
),
verbose_name
=
_
(
'disks'
))
verbose_name
=
_
(
'disks'
))
...
@@ -258,6 +249,19 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -258,6 +249,19 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
parts
=
[
self
.
name
,
"("
+
str
(
self
.
id
)
+
")"
]
parts
=
[
self
.
name
,
"("
+
str
(
self
.
id
)
+
")"
]
return
" "
.
join
([
s
for
s
in
parts
if
s
!=
""
])
return
" "
.
join
([
s
for
s
in
parts
if
s
!=
""
])
@property
def
state
(
self
):
"""State of the virtual machine instance.
"""
if
self
.
activity_log
.
filter
(
activity_code__endswith
=
'migrate'
,
finished__isnull
=
True
)
.
exists
():
return
'MIGRATING'
act
=
next
(
self
.
activity_log
.
filter
(
finished__isnull
=
False
,
resultant_state__isnull
=
False
)
.
order_by
(
'-finished'
)[:
1
],
None
)
return
'NOSTATE'
if
act
is
None
else
act
.
resultant_state
def
clean
(
self
,
*
args
,
**
kwargs
):
def
clean
(
self
,
*
args
,
**
kwargs
):
if
self
.
time_of_delete
is
None
:
if
self
.
time_of_delete
is
None
:
self
.
renew
(
which
=
'delete'
)
self
.
renew
(
which
=
'delete'
)
...
@@ -914,6 +918,4 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -914,6 +918,4 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
logger
.
info
(
'Instance
%
s state change ignored:
%
s'
,
logger
.
info
(
'Instance
%
s state change ignored:
%
s'
,
unicode
(
self
),
unicode
(
e
))
unicode
(
self
),
unicode
(
e
))
else
:
else
:
self
.
state
=
new_state
self
.
save
()
post_state_changed
.
send
(
sender
=
self
,
new_state
=
new_state
)
post_state_changed
.
send
(
sender
=
self
,
new_state
=
new_state
)
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