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
71932249
authored
Feb 07, 2014
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: moved shutdown confirmation to vmdriver
parent
50bc0a0e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
27 deletions
+3
-27
circle/vm/models/instance.py
+2
-26
circle/vm/models/node.py
+1
-1
No files found.
circle/vm/models/instance.py
View file @
71932249
...
...
@@ -2,7 +2,6 @@ from __future__ import absolute_import, unicode_literals
from
datetime
import
timedelta
from
logging
import
getLogger
from
importlib
import
import_module
from
Queue
import
Empty
,
Full
,
Queue
import
string
import
django.conf
...
...
@@ -210,7 +209,6 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
"destruction."
))
objects
=
Manager
()
active
=
InstanceActiveManager
()
libvirt_state_queue
=
Queue
(
maxsize
=
10
)
class
Meta
:
app_label
=
'vm'
...
...
@@ -252,13 +250,6 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
parts
=
[
self
.
name
,
"("
+
str
(
self
.
id
)
+
")"
]
return
" "
.
join
([
s
for
s
in
parts
if
s
!=
""
])
def
__clear_libvirt_state_queue
(
self
):
while
True
:
try
:
self
.
libvirt_state_queue
.
get_nowait
()
except
Empty
:
break
@property
def
state
(
self
):
"""State of the virtual machine instance.
...
...
@@ -275,11 +266,8 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
act
=
None
return
'NOSTATE'
if
act
is
None
else
act
.
resultant_state
def
state_changed
(
self
,
state
):
try
:
self
.
libvirt_state_queue
.
put_nowait
(
state
)
except
Full
:
pass
def
vm_state_changed
(
self
,
new_state
):
pass
def
clean
(
self
,
*
args
,
**
kwargs
):
if
self
.
time_of_delete
is
None
:
...
...
@@ -826,20 +814,8 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
task_uuid
=
task_uuid
,
user
=
user
):
queue_name
=
self
.
get_remote_queue_name
(
'vm'
)
self
.
__clear_libvirt_state_queue
()
vm_tasks
.
shutdown
.
apply_async
(
args
=
[
self
.
vm_name
],
queue
=
queue_name
)
.
get
()
i
=
2
while
i
>
0
:
try
:
libvirt_state
=
self
.
libvirt_state_queue
.
get
(
True
,
60
)
except
Empty
:
raise
TimeoutError
()
else
:
if
libvirt_state
==
'MISSING'
:
break
else
:
i
-=
1
def
shutdown_async
(
self
,
user
=
None
):
"""Execute shutdown asynchronously.
...
...
circle/vm/models/node.py
View file @
71932249
...
...
@@ -170,7 +170,7 @@ class Node(TimeStampedModel):
logger
.
info
(
'Node
%
s update: instance
%
s state changed '
'(libvirt:
%
s, db:
%
s)'
,
self
,
i
[
'id'
],
d
,
i
[
'state'
])
self
.
instance_set
.
get
(
id
=
i
[
'id'
])
.
state_changed
(
d
)
self
.
instance_set
.
get
(
id
=
i
[
'id'
])
.
vm_
state_changed
(
d
)
del
domains
[
i
[
'id'
]]
for
i
in
domains
.
keys
():
...
...
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