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
e72eb8cc
authored
Feb 13, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one: add transient (waiting) state for Instance
fixes
#48
parent
d6721c9c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
8 deletions
+15
-8
one/migrations/0012_auto__add_field_instance_waiting.py
+0
-0
one/models.py
+9
-1
one/templates/box-vmlist.html
+6
-7
No files found.
one/migrations/0012_auto__add_field_instance_waiting.py
0 → 100644
View file @
e72eb8cc
This diff is collapsed.
Click to expand it.
one/models.py
View file @
e72eb8cc
...
...
@@ -353,7 +353,7 @@ class Instance(models.Model):
(
'DONE'
,
_
(
'done'
)),
(
'ACTIVE'
,
_
(
'active'
)),
(
'UNKNOWN'
,
_
(
'unknown'
)),
(
'S
USPEND
ED'
,
_
(
'suspended'
)),
(
'S
TOPP
ED'
,
_
(
'suspended'
)),
(
'FAILED'
,
_
(
'failed'
))],
default
=
'DEPLOYABLE'
)
active_since
=
models
.
DateTimeField
(
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'active since'
),
...
...
@@ -364,6 +364,7 @@ class Instance(models.Model):
share
=
models
.
ForeignKey
(
'Share'
,
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'share'
))
time_of_suspend
=
models
.
DateTimeField
(
default
=
None
,
verbose_name
=
_
(
'time of suspend'
),
null
=
True
,
blank
=
False
)
time_of_delete
=
models
.
DateTimeField
(
default
=
None
,
verbose_name
=
_
(
'time of delete'
),
null
=
True
,
blank
=
False
)
waiting
=
models
.
BooleanField
(
default
=
False
)
"""
Get public port number for default access method.
"""
...
...
@@ -413,6 +414,7 @@ class Instance(models.Model):
"
%
d"
%
self
.
one_id
],
stdout
=
subprocess
.
PIPE
)
(
out
,
err
)
=
proc
.
communicate
()
x
=
None
old_state
=
self
.
state
try
:
from
xml.dom.minidom
import
parse
,
parseString
x
=
parseString
(
out
)
...
...
@@ -421,6 +423,8 @@ class Instance(models.Model):
self
.
state
=
state
except
:
self
.
state
=
'UNKNOWN'
if
self
.
state
!=
old_state
:
self
.
waiting
=
False
self
.
save
()
if
self
.
template
.
state
==
'SAVING'
:
self
.
check_if_is_save_as_done
()
...
...
@@ -575,6 +579,8 @@ class Instance(models.Model):
def
stop
(
self
):
self
.
_change_state
(
"STOPPED"
)
self
.
waiting
=
True
self
.
save
()
def
resume
(
self
):
self
.
_change_state
(
"RESUME"
)
def
poweroff
(
self
):
...
...
@@ -596,6 +602,8 @@ class Instance(models.Model):
imgname
=
"template-
%
d-
%
d"
%
(
self
.
template
.
id
,
self
.
id
)
self
.
_update_vm
(
'<DISK id="0"><SAVE_AS name="
%
s"/></DISK>'
%
imgname
)
self
.
_change_state
(
"SHUTDOWN"
)
self
.
waiting
=
True
self
.
save
()
t
=
self
.
template
t
.
state
=
'SAVING'
t
.
save
()
...
...
one/templates/box-vmlist.html
View file @
e72eb8cc
...
...
@@ -9,7 +9,9 @@
<div
class=
"name {% if i.state == 'ACTIVE' %}wm-on{% else %}wm-off{% endif %}"
>
{{i.name|truncatechars:20}}
</div>
<div
class=
"status"
>
{{i.state}}
</div>
<div
class=
"actions"
>
{% if i.state == 'ACTIVE' %}
{% if i.waiting %}
<img
src=
"/static/load.gif"
/>
{% elif i.state == 'ACTIVE' %}
<a
href=
"{{i.get_connect_uri}}"
data-id=
"{{ i.id }}"
class=
"connect-vm-button"
title=
"{% trans "
Connect
"
%}"
>
<img
src=
"/static/icons/plug.png"
alt=
"{% trans "
Connect
"
%}"
/>
</a>
...
...
@@ -22,20 +24,17 @@
<a
href=
"#"
class=
"restart-vm-button"
data-name=
"{{ i.name}}"
data-id=
"{{ i.id }}"
title=
"{% trans "
Restart
"
%}"
>
<img
src=
"/static/icons/arrow-circle-double.png"
alt=
"↺"
/>
</a>
{% endif %}
{% if i.state == 'PENDING' %}
{% elif i.state == 'PENDING' %}
<img
src=
"/static/load.gif"
/>
{% trans "starting…" %}
{% endif %}
{% if i.state == 'STOPPED' %}
{% elif i.state == 'STOPPED' %}
<a
href=
"#"
class=
"resume-vm-button"
data-name=
"{{ i.name}}"
data-id=
"{{ i.id }}"
title=
"{% trans "
Resume
"
%}"
>
<img
src=
"/static/icons/control.png"
alt=
"{% trans "
Resume
"
%}"
/>
</span>
<a
href=
"#"
class=
"delete-vm-button"
data-name=
"{{ i.name}}"
data-id=
"{{ i.id }}"
title=
"{% trans "
Delete
"
%}"
>
<img
src=
"/static/icons/minus-circle.png"
alt=
"{% trans "
Delete
"
%}"
/>
</a>
{% endif %}
{% if i.state == 'FAILED' %}
{% elif i.state == 'FAILED' %}
<a
href=
"#"
class=
"delete-vm-button"
data-name=
"{{ i.name}}"
data-id=
"{{ i.id }}"
title=
"{% trans "
Delete
"
%}"
>
<img
src=
"/static/icons/minus-circle.png"
alt=
"{% trans "
Delete
"
%}"
/>
</a>
...
...
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