Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
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):
...
@@ -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
({
context
.
update
({
'running_vms'
:
instances
.
filter
(
state
=
'RUNNING'
),
'running_vms'
:
running
,
'running_vm_num'
:
instances
.
filter
(
state
=
'RUNNING'
)
.
count
(),
'running_vm_num'
:
len
(
running
),
'stopped_vm_num'
:
instances
.
exclude
(
'stopped_vm_num'
:
len
(
stopped
)
state__in
=
[
'RUNNING'
,
'NOSTATE'
])
.
count
()
})
})
context
[
'templates'
]
=
InstanceTemplate
.
objects
.
all
()[:
5
]
context
[
'templates'
]
=
InstanceTemplate
.
objects
.
all
()[:
5
]
...
...
circle/storage/models.py
View file @
b0db4153
...
@@ -117,7 +117,7 @@ class Disk(AclBase, TimeStampedModel):
...
@@ -117,7 +117,7 @@ class Disk(AclBase, TimeStampedModel):
}[
self
.
type
]
}[
self
.
type
]
def
is_in_use
(
self
):
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
):
def
get_exclusive
(
self
):
"""Get an instance of the disk for exclusive usage.
"""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):
...
@@ -267,12 +267,15 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
finished__isnull
=
True
)
.
exists
():
finished__isnull
=
True
)
.
exists
():
return
'MIGRATING'
return
'MIGRATING'
act
=
next
(
self
.
activity_log
.
filter
(
finished__isnull
=
False
,
try
:
resultant_state__isnull
=
False
)
act
=
self
.
activity_log
.
filter
(
finished__isnull
=
False
,
.
order_by
(
'-finished'
)[:
1
],
None
)
resultant_state__isnull
=
False
)
.
order_by
(
'-finished'
)
.
all
()[
0
]
except
IndexError
:
act
=
None
return
'NOSTATE'
if
act
is
None
else
act
.
resultant_state
return
'NOSTATE'
if
act
is
None
else
act
.
resultant_state
def
state_chaged
(
self
,
state
):
def
state_cha
n
ged
(
self
,
state
):
try
:
try
:
self
.
libvirt_state_queue
.
put_nowait
(
state
)
self
.
libvirt_state_queue
.
put_nowait
(
state
)
except
Full
:
except
Full
:
...
...
circle/vm/models/node.py
View file @
b0db4153
...
@@ -157,7 +157,8 @@ class Node(TimeStampedModel):
...
@@ -157,7 +157,8 @@ class Node(TimeStampedModel):
else
:
else
:
domains
[
id
]
=
i
[
'state'
]
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
:
for
i
in
instances
:
try
:
try
:
d
=
domains
[
i
[
'id'
]]
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