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
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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
26 deletions
+2
-26
circle/vm/models/instance.py
+1
-25
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
...
@@ -2,7 +2,6 @@ from __future__ import absolute_import, unicode_literals
from
datetime
import
timedelta
from
datetime
import
timedelta
from
logging
import
getLogger
from
logging
import
getLogger
from
importlib
import
import_module
from
importlib
import
import_module
from
Queue
import
Empty
,
Full
,
Queue
import
string
import
string
import
django.conf
import
django.conf
...
@@ -210,7 +209,6 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -210,7 +209,6 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
"destruction."
))
"destruction."
))
objects
=
Manager
()
objects
=
Manager
()
active
=
InstanceActiveManager
()
active
=
InstanceActiveManager
()
libvirt_state_queue
=
Queue
(
maxsize
=
10
)
class
Meta
:
class
Meta
:
app_label
=
'vm'
app_label
=
'vm'
...
@@ -252,13 +250,6 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -252,13 +250,6 @@ 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
!=
""
])
def
__clear_libvirt_state_queue
(
self
):
while
True
:
try
:
self
.
libvirt_state_queue
.
get_nowait
()
except
Empty
:
break
@property
@property
def
state
(
self
):
def
state
(
self
):
"""State of the virtual machine instance.
"""State of the virtual machine instance.
...
@@ -275,10 +266,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -275,10 +266,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
act
=
None
act
=
None
return
'NOSTATE'
if
act
is
None
else
act
.
resultant_state
return
'NOSTATE'
if
act
is
None
else
act
.
resultant_state
def
state_changed
(
self
,
state
):
def
vm_state_changed
(
self
,
new_state
):
try
:
self
.
libvirt_state_queue
.
put_nowait
(
state
)
except
Full
:
pass
pass
def
clean
(
self
,
*
args
,
**
kwargs
):
def
clean
(
self
,
*
args
,
**
kwargs
):
...
@@ -826,20 +814,8 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -826,20 +814,8 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
task_uuid
=
task_uuid
,
user
=
user
):
task_uuid
=
task_uuid
,
user
=
user
):
queue_name
=
self
.
get_remote_queue_name
(
'vm'
)
queue_name
=
self
.
get_remote_queue_name
(
'vm'
)
self
.
__clear_libvirt_state_queue
()
vm_tasks
.
shutdown
.
apply_async
(
args
=
[
self
.
vm_name
],
vm_tasks
.
shutdown
.
apply_async
(
args
=
[
self
.
vm_name
],
queue
=
queue_name
)
.
get
()
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
):
def
shutdown_async
(
self
,
user
=
None
):
"""Execute shutdown asynchronously.
"""Execute shutdown asynchronously.
...
...
circle/vm/models/node.py
View file @
71932249
...
@@ -170,7 +170,7 @@ class Node(TimeStampedModel):
...
@@ -170,7 +170,7 @@ class Node(TimeStampedModel):
logger
.
info
(
'Node
%
s update: instance
%
s state changed '
logger
.
info
(
'Node
%
s update: instance
%
s state changed '
'(libvirt:
%
s, db:
%
s)'
,
'(libvirt:
%
s, db:
%
s)'
,
self
,
i
[
'id'
],
d
,
i
[
'state'
])
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'
]]
del
domains
[
i
[
'id'
]]
for
i
in
domains
.
keys
():
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