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
b0db4153
authored
Feb 06, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: fix more legacy 'state' field uses
parent
74bd1375
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
10 deletions
+15
-10
circle/dashboard/views.py
+5
-4
circle/storage/models.py
+1
-1
circle/vm/models/instance.py
+7
-4
circle/vm/models/node.py
+2
-1
No files found.
circle/dashboard/views.py
View file @
b0db4153
...
...
@@ -95,11 +95,12 @@ class IndexView(LoginRequiredMixin, TemplateView):
}
})
running
=
[
i
for
i
in
instances
if
i
.
state
==
'RUNNING'
]
stopped
=
[
i
for
i
in
instances
if
i
.
state
not
in
[
'RUNNING'
,
'NOSTATE'
]]
context
.
update
({
'running_vms'
:
instances
.
filter
(
state
=
'RUNNING'
),
'running_vm_num'
:
instances
.
filter
(
state
=
'RUNNING'
)
.
count
(),
'stopped_vm_num'
:
instances
.
exclude
(
state__in
=
[
'RUNNING'
,
'NOSTATE'
])
.
count
()
'running_vms'
:
running
,
'running_vm_num'
:
len
(
running
),
'stopped_vm_num'
:
len
(
stopped
)
})
context
[
'templates'
]
=
InstanceTemplate
.
objects
.
all
()[:
5
]
...
...
circle/storage/models.py
View file @
b0db4153
...
...
@@ -117,7 +117,7 @@ class Disk(AclBase, TimeStampedModel):
}[
self
.
type
]
def
is_in_use
(
self
):
return
self
.
instance_set
.
exclude
(
state
=
'SHUTOFF'
)
.
exists
(
)
return
any
([
i
.
state
!=
'SHUTOFF'
for
i
in
self
.
instance_set
.
all
()]
)
def
get_exclusive
(
self
):
"""Get an instance of the disk for exclusive usage.
...
...
circle/vm/models/instance.py
View file @
b0db4153
...
...
@@ -267,12 +267,15 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
finished__isnull
=
True
)
.
exists
():
return
'MIGRATING'
act
=
next
(
self
.
activity_log
.
filter
(
finished__isnull
=
False
,
resultant_state__isnull
=
False
)
.
order_by
(
'-finished'
)[:
1
],
None
)
try
:
act
=
self
.
activity_log
.
filter
(
finished__isnull
=
False
,
resultant_state__isnull
=
False
)
.
order_by
(
'-finished'
)
.
all
()[
0
]
except
IndexError
:
act
=
None
return
'NOSTATE'
if
act
is
None
else
act
.
resultant_state
def
state_chaged
(
self
,
state
):
def
state_cha
n
ged
(
self
,
state
):
try
:
self
.
libvirt_state_queue
.
put_nowait
(
state
)
except
Full
:
...
...
circle/vm/models/node.py
View file @
b0db4153
...
...
@@ -157,7 +157,8 @@ class Node(TimeStampedModel):
else
:
domains
[
id
]
=
i
[
'state'
]
instances
=
self
.
instance_set
.
order_by
(
'id'
)
.
values
(
'id'
,
'state'
)
instances
=
[{
'id'
:
i
.
id
,
'state'
:
i
.
state
}
for
i
in
self
.
instance_set
.
order_by
(
'id'
)
.
all
()]
for
i
in
instances
:
try
:
d
=
domains
[
i
[
'id'
]]
...
...
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