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
0c2709fa
authored
Sep 22, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue-295' into 'master'
Issue 295
parents
91843cc1
80512ca6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
13 deletions
+14
-13
circle/vm/models/instance.py
+7
-6
circle/vm/models/node.py
+7
-4
circle/vm/operations.py
+0
-3
No files found.
circle/vm/models/instance.py
View file @
0c2709fa
...
@@ -447,21 +447,22 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
...
@@ -447,21 +447,22 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
self
.
time_of_suspend
,
self
.
time_of_delete
=
self
.
get_renew_times
()
self
.
time_of_suspend
,
self
.
time_of_delete
=
self
.
get_renew_times
()
super
(
Instance
,
self
)
.
clean
(
*
args
,
**
kwargs
)
super
(
Instance
,
self
)
.
clean
(
*
args
,
**
kwargs
)
def
vm_state_changed
(
self
,
new_state
):
def
vm_state_changed
(
self
,
new_state
,
new_node
=
False
):
if
new_node
is
False
:
# None would be a valid value
new_node
=
self
.
node
# log state change
# log state change
try
:
try
:
act
=
InstanceActivity
.
create
(
act
=
InstanceActivity
.
create
(
code_suffix
=
'vm_state_changed'
,
code_suffix
=
'vm_state_changed'
,
readable_name
=
create_readable
(
readable_name
=
create_readable
(
ugettext_noop
(
"vm state changed to
%(state)
s"
),
ugettext_noop
(
"vm state changed to
%(state)
s
on
%(node)
s
"
),
state
=
new_state
),
state
=
new_state
,
node
=
new_node
),
instance
=
self
)
instance
=
self
)
except
ActivityInProgressError
:
except
ActivityInProgressError
:
pass
# discard state change if another activity is in progress.
pass
# discard state change if another activity is in progress.
else
:
else
:
if
new_state
==
'STOPPED'
:
if
self
.
node
!=
new_node
:
self
.
vnc_port
=
None
self
.
node
=
new_node
self
.
node
=
None
self
.
save
()
self
.
save
()
act
.
finished
=
act
.
started
act
.
finished
=
act
.
started
act
.
resultant_state
=
new_state
act
.
resultant_state
=
new_state
...
...
circle/vm/models/node.py
View file @
0c2709fa
...
@@ -354,7 +354,8 @@ class Node(OperatedMixin, TimeStampedModel):
...
@@ -354,7 +354,8 @@ class Node(OperatedMixin, TimeStampedModel):
logger
.
info
(
'Node
%
s update: instance
%
s missing from '
logger
.
info
(
'Node
%
s update: instance
%
s missing from '
'libvirt'
,
self
,
i
[
'id'
])
'libvirt'
,
self
,
i
[
'id'
])
# Set state to STOPPED when instance is missing
# Set state to STOPPED when instance is missing
self
.
instance_set
.
get
(
id
=
i
[
'id'
])
.
vm_state_changed
(
'STOPPED'
)
self
.
instance_set
.
get
(
id
=
i
[
'id'
])
.
vm_state_changed
(
'STOPPED'
,
None
)
else
:
else
:
if
d
!=
i
[
'state'
]:
if
d
!=
i
[
'state'
]:
logger
.
info
(
'Node
%
s update: instance
%
s state changed '
logger
.
info
(
'Node
%
s update: instance
%
s state changed '
...
@@ -363,9 +364,11 @@ class Node(OperatedMixin, TimeStampedModel):
...
@@ -363,9 +364,11 @@ class Node(OperatedMixin, TimeStampedModel):
self
.
instance_set
.
get
(
id
=
i
[
'id'
])
.
vm_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
id
,
state
in
domains
.
iteritems
():
logger
.
info
(
'Node
%
s update: domain
%
s in libvirt but not in db.'
,
from
.instance
import
Instance
self
,
i
)
logger
.
error
(
'Node
%
s update: domain
%
s in libvirt but not in db.'
,
self
,
id
)
Instance
.
objects
.
get
(
id
=
id
)
.
vm_state_changed
(
state
,
self
)
@classmethod
@classmethod
def
get_state_count
(
cls
,
online
,
enabled
):
def
get_state_count
(
cls
,
online
,
enabled
):
...
...
circle/vm/operations.py
View file @
0c2709fa
...
@@ -629,7 +629,6 @@ class ShutdownOperation(InstanceOperation):
...
@@ -629,7 +629,6 @@ class ShutdownOperation(InstanceOperation):
def
_operation
(
self
,
task
=
None
):
def
_operation
(
self
,
task
=
None
):
self
.
instance
.
shutdown_vm
(
task
=
task
)
self
.
instance
.
shutdown_vm
(
task
=
task
)
self
.
instance
.
yield_node
()
self
.
instance
.
yield_node
()
self
.
instance
.
yield_vnc_port
()
def
on_abort
(
self
,
activity
,
error
):
def
on_abort
(
self
,
activity
,
error
):
if
isinstance
(
error
,
TimeLimitExceeded
):
if
isinstance
(
error
,
TimeLimitExceeded
):
...
@@ -670,9 +669,7 @@ class ShutOffOperation(InstanceOperation):
...
@@ -670,9 +669,7 @@ class ShutOffOperation(InstanceOperation):
with
activity
.
sub_activity
(
'delete_vm'
):
with
activity
.
sub_activity
(
'delete_vm'
):
self
.
instance
.
delete_vm
()
self
.
instance
.
delete_vm
()
# Clear node and VNC port association
self
.
instance
.
yield_node
()
self
.
instance
.
yield_node
()
self
.
instance
.
yield_vnc_port
()
register_operation
(
ShutOffOperation
)
register_operation
(
ShutOffOperation
)
...
...
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