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
340d9070
authored
Feb 12, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one: add renew function
parent
47e39346
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
0 deletions
+47
-0
cloud/urls.py
+1
-0
one/models.py
+8
-0
one/static/cloud.js
+22
-0
one/static/icons/control-double.png
+0
-0
one/templates/box-vmlist.html
+6
-0
one/views.py
+10
-0
No files found.
cloud/urls.py
View file @
340d9070
...
@@ -27,6 +27,7 @@ urlpatterns = patterns('',
...
@@ -27,6 +27,7 @@ urlpatterns = patterns('',
url
(
r'^vm/resume/(?P<iid>\d+)/$'
,
'one.views.vm_resume'
,
name
=
'vm_resume'
),
url
(
r'^vm/resume/(?P<iid>\d+)/$'
,
'one.views.vm_resume'
,
name
=
'vm_resume'
),
url
(
r'^vm/power_off/(?P<iid>\d+)/$'
,
'one.views.vm_power_off'
,
name
=
'vm_power_off'
),
url
(
r'^vm/power_off/(?P<iid>\d+)/$'
,
'one.views.vm_power_off'
,
name
=
'vm_power_off'
),
url
(
r'^vm/restart/(?P<iid>\d+)/$'
,
'one.views.vm_restart'
,
name
=
'vm_restart'
),
url
(
r'^vm/restart/(?P<iid>\d+)/$'
,
'one.views.vm_restart'
,
name
=
'vm_restart'
),
url
(
r'^vm/renew/(?P<which>(suspend|delete))/(?P<iid>\d+)/$'
,
'one.views.vm_renew'
,
name
=
'vm_renew'
),
url
(
r'^vm/port_add/(?P<iid>\d+)/$'
,
'one.views.vm_port_add'
,
name
=
'vm_port_add'
),
url
(
r'^vm/port_add/(?P<iid>\d+)/$'
,
'one.views.vm_port_add'
,
name
=
'vm_port_add'
),
url
(
r'^vm/port_del/(?P<iid>\d+)/(?P<proto>tcp|udp)/(?P<public>\d+)/$'
,
'one.views.vm_port_del'
,
name
=
'vm_port_del'
),
url
(
r'^vm/port_del/(?P<iid>\d+)/(?P<proto>tcp|udp)/(?P<public>\d+)/$'
,
'one.views.vm_port_del'
,
name
=
'vm_port_del'
),
url
(
r'^vm/saveas/(?P<vmid>\d+)$'
,
'one.views.vm_saveas'
,
name
=
'vm_saveas'
),
url
(
r'^vm/saveas/(?P<vmid>\d+)$'
,
'one.views.vm_saveas'
,
name
=
'vm_saveas'
),
...
...
one/models.py
View file @
340d9070
...
@@ -581,6 +581,14 @@ class Instance(models.Model):
...
@@ -581,6 +581,14 @@ class Instance(models.Model):
self
.
_change_state
(
"POWEROFF"
)
self
.
_change_state
(
"POWEROFF"
)
def
restart
(
self
):
def
restart
(
self
):
self
.
_change_state
(
"RESET"
)
self
.
_change_state
(
"RESET"
)
def
renew
(
self
,
which
):
if
which
==
'suspend'
:
self
.
time_of_suspend
=
self
.
share
.
get_type
()[
'suspendx'
]
elif
which
==
'delete'
:
self
.
time_of_delete
=
self
.
share
.
get_type
()[
'deletex'
]
else
:
raise
ValueError
(
'No such expiration type.'
)
self
.
save
()
def
save_as
(
self
):
def
save_as
(
self
):
"""
"""
Save image and shut down.
Save image and shut down.
...
...
one/static/cloud.js
View file @
340d9070
...
@@ -72,6 +72,14 @@ $(function() {
...
@@ -72,6 +72,14 @@ $(function() {
e
.
preventDefault
();
e
.
stopPropagation
();
e
.
preventDefault
();
e
.
stopPropagation
();
restart_vm
(
$
(
this
).
data
(
'id'
),
$
(
this
).
data
(
'name'
));
restart_vm
(
$
(
this
).
data
(
'id'
),
$
(
this
).
data
(
'name'
));
});
});
$
(
'.renew-suspend-vm-button'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
renew_suspend_vm
(
$
(
this
).
data
(
'id'
))
});
$
(
'.renew-delete-vm-button'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
renew_delete_vm
(
$
(
this
).
data
(
'id'
))
});
$
(
'#new-wm-button'
).
click
(
function
()
{
$
(
'#new-wm-button'
).
click
(
function
()
{
$
(
'#modal'
).
show
();
$
(
'#modal'
).
show
();
$
(
'#modal-container'
).
html
(
$
(
'#new-wm'
).
html
());
$
(
'#modal-container'
).
html
(
$
(
'#new-wm'
).
html
());
...
@@ -195,6 +203,20 @@ $(function() {
...
@@ -195,6 +203,20 @@ $(function() {
manage_vm
(
id
,
"resume"
)
manage_vm
(
id
,
"resume"
)
}
}
/**
/**
* Renew vm suspend time.
*/
function
renew_suspend_vm
(
id
)
{
manage_vm
(
id
,
"renew/suspend"
)
}
/**
* Renew vm deletion time.
*/
function
renew_delete_vm
(
id
)
{
manage_vm
(
id
,
"renew/delete"
)
}
/**
* Manage VM State generic
* Manage VM State generic
*/
*/
...
...
one/static/icons/control-double.png
0 → 100644
View file @
340d9070
564 Bytes
one/templates/box-vmlist.html
View file @
340d9070
...
@@ -88,6 +88,9 @@
...
@@ -88,6 +88,9 @@
<li
class=
"date"
>
<li
class=
"date"
>
{% trans "time of suspend"|capfirst %}:
{% trans "time of suspend"|capfirst %}:
<span
class=
"value"
>
<abbr
title=
"{{i.time_of_suspend}}"
>
{{i.time_of_suspend|timeuntil}}
</abbr>
<span
class=
"value"
>
<abbr
title=
"{{i.time_of_suspend}}"
>
{{i.time_of_suspend|timeuntil}}
</abbr>
<a
href=
"#"
class=
"renew-vm-button renew-suspend-vm-button"
data-id=
"{{ i.id }}"
title=
"{% trans "
Renew
suspend
time
"
%}"
>
<img
src=
"/static/icons/control-double.png"
alt=
"{% trans "
Renew
suspend
time
"
%}"
/>
</a>
</span>
</span>
</li>
</li>
{% endif %}
{% endif %}
...
@@ -95,6 +98,9 @@
...
@@ -95,6 +98,9 @@
<li
class=
"date"
>
<li
class=
"date"
>
{% trans "time of delete"|capfirst %}:
{% trans "time of delete"|capfirst %}:
<span
class=
"value"
>
<abbr
title=
"{{i.time_of_delete}}"
>
{{i.time_of_delete|timeuntil}}
</abbr>
<span
class=
"value"
>
<abbr
title=
"{{i.time_of_delete}}"
>
{{i.time_of_delete|timeuntil}}
</abbr>
<a
href=
"#"
class=
"renew-vm-button renew-delete-vm-button"
data-id=
"{{ i.id }}"
title=
"{% trans "
Renew
deletion
time
"
%}"
>
<img
src=
"/static/icons/control-double.png"
alt=
"{% trans "
Renew
deletion
time
"
%}"
/>
</a>
</span>
</span>
</li>
</li>
{% endif %}
{% endif %}
...
...
one/views.py
View file @
340d9070
...
@@ -421,6 +421,16 @@ def vm_resume(request, iid, *args, **kwargs):
...
@@ -421,6 +421,16 @@ def vm_resume(request, iid, *args, **kwargs):
@login_required
@login_required
@require_POST
@require_POST
def
vm_renew
(
request
,
which
,
iid
,
*
args
,
**
kwargs
):
try
:
get_object_or_404
(
Instance
,
id
=
iid
,
owner
=
request
.
user
)
.
renew
(
which
)
messages
.
success
(
request
,
_
(
'Virtual machine is successfully renewed.'
))
except
:
messages
.
error
(
request
,
_
(
'Failed to renew virtual machine.'
))
return
redirect
(
'/'
)
@login_required
@require_POST
def
vm_power_off
(
request
,
iid
,
*
args
,
**
kwargs
):
def
vm_power_off
(
request
,
iid
,
*
args
,
**
kwargs
):
try
:
try
:
get_object_or_404
(
Instance
,
id
=
iid
,
owner
=
request
.
user
)
.
poweroff
()
get_object_or_404
(
Instance
,
id
=
iid
,
owner
=
request
.
user
)
.
poweroff
()
...
...
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