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):
...
@@ -353,7 +353,7 @@ class Instance(models.Model):
(
'DONE'
,
_
(
'done'
)),
(
'DONE'
,
_
(
'done'
)),
(
'ACTIVE'
,
_
(
'active'
)),
(
'ACTIVE'
,
_
(
'active'
)),
(
'UNKNOWN'
,
_
(
'unknown'
)),
(
'UNKNOWN'
,
_
(
'unknown'
)),
(
'S
USPEND
ED'
,
_
(
'suspended'
)),
(
'S
TOPP
ED'
,
_
(
'suspended'
)),
(
'FAILED'
,
_
(
'failed'
))],
default
=
'DEPLOYABLE'
)
(
'FAILED'
,
_
(
'failed'
))],
default
=
'DEPLOYABLE'
)
active_since
=
models
.
DateTimeField
(
null
=
True
,
blank
=
True
,
active_since
=
models
.
DateTimeField
(
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'active since'
),
verbose_name
=
_
(
'active since'
),
...
@@ -364,6 +364,7 @@ class Instance(models.Model):
...
@@ -364,6 +364,7 @@ class Instance(models.Model):
share
=
models
.
ForeignKey
(
'Share'
,
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'share'
))
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_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
)
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.
Get public port number for default access method.
"""
"""
...
@@ -413,6 +414,7 @@ class Instance(models.Model):
...
@@ -413,6 +414,7 @@ class Instance(models.Model):
"
%
d"
%
self
.
one_id
],
stdout
=
subprocess
.
PIPE
)
"
%
d"
%
self
.
one_id
],
stdout
=
subprocess
.
PIPE
)
(
out
,
err
)
=
proc
.
communicate
()
(
out
,
err
)
=
proc
.
communicate
()
x
=
None
x
=
None
old_state
=
self
.
state
try
:
try
:
from
xml.dom.minidom
import
parse
,
parseString
from
xml.dom.minidom
import
parse
,
parseString
x
=
parseString
(
out
)
x
=
parseString
(
out
)
...
@@ -421,6 +423,8 @@ class Instance(models.Model):
...
@@ -421,6 +423,8 @@ class Instance(models.Model):
self
.
state
=
state
self
.
state
=
state
except
:
except
:
self
.
state
=
'UNKNOWN'
self
.
state
=
'UNKNOWN'
if
self
.
state
!=
old_state
:
self
.
waiting
=
False
self
.
save
()
self
.
save
()
if
self
.
template
.
state
==
'SAVING'
:
if
self
.
template
.
state
==
'SAVING'
:
self
.
check_if_is_save_as_done
()
self
.
check_if_is_save_as_done
()
...
@@ -575,6 +579,8 @@ class Instance(models.Model):
...
@@ -575,6 +579,8 @@ class Instance(models.Model):
def
stop
(
self
):
def
stop
(
self
):
self
.
_change_state
(
"STOPPED"
)
self
.
_change_state
(
"STOPPED"
)
self
.
waiting
=
True
self
.
save
()
def
resume
(
self
):
def
resume
(
self
):
self
.
_change_state
(
"RESUME"
)
self
.
_change_state
(
"RESUME"
)
def
poweroff
(
self
):
def
poweroff
(
self
):
...
@@ -596,6 +602,8 @@ class Instance(models.Model):
...
@@ -596,6 +602,8 @@ class Instance(models.Model):
imgname
=
"template-
%
d-
%
d"
%
(
self
.
template
.
id
,
self
.
id
)
imgname
=
"template-
%
d-
%
d"
%
(
self
.
template
.
id
,
self
.
id
)
self
.
_update_vm
(
'<DISK id="0"><SAVE_AS name="
%
s"/></DISK>'
%
imgname
)
self
.
_update_vm
(
'<DISK id="0"><SAVE_AS name="
%
s"/></DISK>'
%
imgname
)
self
.
_change_state
(
"SHUTDOWN"
)
self
.
_change_state
(
"SHUTDOWN"
)
self
.
waiting
=
True
self
.
save
()
t
=
self
.
template
t
=
self
.
template
t
.
state
=
'SAVING'
t
.
state
=
'SAVING'
t
.
save
()
t
.
save
()
...
...
one/templates/box-vmlist.html
View file @
e72eb8cc
...
@@ -9,7 +9,9 @@
...
@@ -9,7 +9,9 @@
<div
class=
"name {% if i.state == 'ACTIVE' %}wm-on{% else %}wm-off{% endif %}"
>
{{i.name|truncatechars:20}}
</div>
<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=
"status"
>
{{i.state}}
</div>
<div
class=
"actions"
>
<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
"
%}"
>
<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
"
%}"
/>
<img
src=
"/static/icons/plug.png"
alt=
"{% trans "
Connect
"
%}"
/>
</a>
</a>
...
@@ -22,20 +24,17 @@
...
@@ -22,20 +24,17 @@
<a
href=
"#"
class=
"restart-vm-button"
data-name=
"{{ i.name}}"
data-id=
"{{ i.id }}"
title=
"{% trans "
Restart
"
%}"
>
<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=
"↺"
/>
<img
src=
"/static/icons/arrow-circle-double.png"
alt=
"↺"
/>
</a>
</a>
{% endif %}
{% elif i.state == 'PENDING' %}
{% if i.state == 'PENDING' %}
<img
src=
"/static/load.gif"
/>
<img
src=
"/static/load.gif"
/>
{% trans "starting…" %}
{% trans "starting…" %}
{% endif %}
{% elif i.state == 'STOPPED' %}
{% if i.state == 'STOPPED' %}
<a
href=
"#"
class=
"resume-vm-button"
data-name=
"{{ i.name}}"
data-id=
"{{ i.id }}"
title=
"{% trans "
Resume
"
%}"
>
<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
"
%}"
/>
<img
src=
"/static/icons/control.png"
alt=
"{% trans "
Resume
"
%}"
/>
</span>
</span>
<a
href=
"#"
class=
"delete-vm-button"
data-name=
"{{ i.name}}"
data-id=
"{{ i.id }}"
title=
"{% trans "
Delete
"
%}"
>
<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
"
%}"
/>
<img
src=
"/static/icons/minus-circle.png"
alt=
"{% trans "
Delete
"
%}"
/>
</a>
</a>
{% endif %}
{% elif i.state == 'FAILED' %}
{% if i.state == 'FAILED' %}
<a
href=
"#"
class=
"delete-vm-button"
data-name=
"{{ i.name}}"
data-id=
"{{ i.id }}"
title=
"{% trans "
Delete
"
%}"
>
<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
"
%}"
/>
<img
src=
"/static/icons/minus-circle.png"
alt=
"{% trans "
Delete
"
%}"
/>
</a>
</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