Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
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
dd0f3dc2
authored
Feb 01, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: saves as template function for vms
parent
7c16e4b9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
12 deletions
+51
-12
circle/dashboard/templates/dashboard/vm-detail.html
+34
-12
circle/dashboard/views.py
+17
-0
No files found.
circle/dashboard/templates/dashboard/vm-detail.html
View file @
dd0f3dc2
...
@@ -4,6 +4,24 @@
...
@@ -4,6 +4,24 @@
{% block content %}
{% block content %}
<div
class=
"body-content"
>
<div
class=
"body-content"
>
<div
class=
"page-header"
>
<div
class=
"page-header"
>
<div
class=
"pull-right"
style=
"padding-top: 15px;"
>
<a
title=
"Rename"
href=
"#"
class=
"btn btn-default btn-xs vm-details-rename-button"
><i
class=
"icon-pencil"
></i></a>
{% if instance.state.lower == "running" %}
<a
title=
"Pause"
href=
"#"
class=
"btn btn-default btn-xs"
><i
class=
"icon-pause"
></i></a>
<a
title=
"Sleep"
href=
"#"
class=
"btn btn-default btn-xs"
><i
class=
"icon-moon"
></i></a>
{% else %}
<a
title=
"Start"
href=
"#"
class=
"btn btn-default btn-xs"
><i
class=
"icon-play"
></i></a>
<a
title=
"Wake up"
href=
"#"
class=
"btn btn-default btn-xs"
><i
class=
"icon-sun"
></i></a>
{% endif %}
<a
title=
"Shut down"
href=
"#"
class=
"btn btn-default btn-xs"
><i
class=
"icon-off"
></i></a>
<a
title=
"Migrate"
href=
"#"
class=
"btn btn-default btn-xs"
><i
class=
"icon-truck"
></i></a>
<form
style=
"display: inline;"
method=
"POST"
action=
"{% url "
dashboard
.
views
.
detail
"
pk=
instance.pk
%}"
>
{% csrf_token %}
<input
type=
"hidden"
name=
"save_as"
value=
"dummy"
/>
<button
title=
"Save as template"
class=
"btn btn-default btn-xs"
type=
"submit"
><i
class=
"icon-save"
></i></button>
</form>
<a
title=
"Destroy"
href=
"{% url "
dashboard
.
views
.
delete-vm
"
pk=
instance.pk
%}"
class=
"btn btn-default btn-xs vm-delete"
data-vm-pk=
"{{ instance.pk }}"
><i
class=
"icon-remove"
></i></a>
</div>
<h1>
<h1>
<div
id=
"vm-details-rename"
>
<div
id=
"vm-details-rename"
>
<form
action=
""
method=
"POST"
id=
"vm-details-rename-form"
>
<form
action=
""
method=
"POST"
id=
"vm-details-rename-form"
>
...
@@ -24,16 +42,15 @@
...
@@ -24,16 +42,15 @@
<div
class=
"btn-group"
>
<div
class=
"btn-group"
>
<button
type=
"button"
class=
"btn btn-warning dropdown-toggle"
data-toggle=
"dropdown"
>
Action
<i
class=
"icon-caret-down"
></i></button>
<button
type=
"button"
class=
"btn btn-warning dropdown-toggle"
data-toggle=
"dropdown"
>
Action
<i
class=
"icon-caret-down"
></i></button>
<ul
class=
"dropdown-menu"
role=
"menu"
>
<ul
class=
"dropdown-menu"
role=
"menu"
>
<li><a
href=
"#"
class=
"vm-details-rename-button"
><i
class=
"icon-pencil"
></i>
Rename
</a></li>
<li><a
href=
"#"
class=
"vm-details-rename-button"
><i
class=
"icon-pencil"
></i>
{% trans "Rename" %}
</a></li>
<li><a
href=
"#"
class=
"vm-details-save-button"
><i
class=
"icon-save"
></i>
Save as
</a></li>
<li><a
data-vm-pk=
"{{ instance.pk }}"
href=
"#"
class=
"vm-details-save-as-button"
><i
class=
"icon-save"
></i>
{% trans "Save as" %}
</a></li>
<li><a
href=
"#"
><i
class=
"icon-refresh"
></i>
Reboot
</a></li>
<li><a
href=
"#"
><i
class=
"icon-refresh"
></i>
{% trans "Reboot" %}
</a></li>
<li><a
href=
"#"
><i
class=
"icon-off"
></i>
Shutdown
</a></li>
<li><a
href=
"#"
><i
class=
"icon-off"
></i>
{% trans "Shutdown" %}
</a></li>
<li><a
data-vm-pk=
"{{ instance.pk }}"
class=
"vm-delete"
href=
"{% url "
dashboard
.
views
.
delete-vm
"
pk=
instance.pk
%}"
><i
class=
"icon-remove"
></i>
Discard
</a></li>
<li><a
data-vm-pk=
"{{ instance.pk }}"
class=
"vm-delete"
href=
"{% url "
dashboard
.
views
.
delete-vm
"
pk=
instance.pk
%}"
><i
class=
"icon-remove"
></i>
{% trans "Discard" %}
</a></li>
</ul>
</ul>
</div>
</div>
</div>
</div>
<h3>
{% trans "Connection" %}
</h3>
<h3>
{% trans "Connection" %}
</h3>
<!-- TODO RDP -->
<input
type=
"text"
value=
"{{ instance.get_connect_command }}"
class=
"form-control"
readonly
/>
<input
type=
"text"
value=
"{{ instance.get_connect_command }}"
class=
"form-control"
readonly
/>
<dl
class=
"dl-horizontal vm-details-pw"
>
<dl
class=
"dl-horizontal vm-details-pw"
>
<dt>
Password:
</dt>
<dt>
Password:
</dt>
...
@@ -65,27 +82,32 @@
...
@@ -65,27 +82,32 @@
<li
class=
"active"
>
<li
class=
"active"
>
<a
href=
"#home"
data-toggle=
"pill"
class=
"text-center"
>
<a
href=
"#home"
data-toggle=
"pill"
class=
"text-center"
>
<i
class=
"icon-compass icon-2x"
></i><br>
<i
class=
"icon-compass icon-2x"
></i><br>
{% trans "Home" %}
</a></li>
{% trans "Home" %}
</a>
</li>
<li>
<li>
<a
href=
"#resources"
data-toggle=
"pill"
class=
"text-center"
>
<a
href=
"#resources"
data-toggle=
"pill"
class=
"text-center"
>
<i
class=
"icon-tasks icon-2x"
></i><br>
<i
class=
"icon-tasks icon-2x"
></i><br>
{% trans "Resources" %}
</a></li>
{% trans "Resources" %}
</a>
<li
{%
if
instance
.
state
!=
"
RUNNING
"
%}
class=
"disabled"
{%
endif
%}
>
</li>
<li
{%
if
instance
.
state
!=
"
RUNNING
"
%}
class=
"disabled"
{%
endif
%}
>
<a
href=
"#{% if instance.state == "
RUNNING
"
%}
console
"
data-toggle=
"pill{% endif %}"
class=
"text-center"
>
<a
href=
"#{% if instance.state == "
RUNNING
"
%}
console
"
data-toggle=
"pill{% endif %}"
class=
"text-center"
>
<i
class=
"icon-desktop icon-2x"
></i><br>
<i
class=
"icon-desktop icon-2x"
></i><br>
{% trans "Console" %}
</a></li>
{% trans "Console" %}
</a></li>
<li>
<li>
<a
href=
"#access"
data-toggle=
"pill"
class=
"text-center"
>
<a
href=
"#access"
data-toggle=
"pill"
class=
"text-center"
>
<i
class=
"icon-group icon-2x"
></i><br>
<i
class=
"icon-group icon-2x"
></i><br>
{% trans "Access" %}
</a></li>
{% trans "Access" %}
</a>
</li>
<li>
<li>
<a
href=
"#network"
data-toggle=
"pill"
class=
"text-center"
>
<a
href=
"#network"
data-toggle=
"pill"
class=
"text-center"
>
<i
class=
"icon-globe icon-2x"
></i><br>
<i
class=
"icon-globe icon-2x"
></i><br>
{% trans "Network" %}
</a></li>
{% trans "Network" %}
</a>
</li>
<li>
<li>
<a
href=
"#activity"
data-toggle=
"pill"
class=
"text-center"
>
<a
href=
"#activity"
data-toggle=
"pill"
class=
"text-center"
>
<i
class=
"icon-time icon-2x"
></i><br>
<i
class=
"icon-time icon-2x"
></i><br>
{% trans "Activity" %}
</a></li>
{% trans "Activity" %}
</a>
</li>
</ul>
</ul>
<div
class=
"tab-content panel-body"
>
<div
class=
"tab-content panel-body"
>
...
...
circle/dashboard/views.py
View file @
dd0f3dc2
...
@@ -2,6 +2,7 @@ from os import getenv
...
@@ -2,6 +2,7 @@ from os import getenv
import
json
import
json
import
logging
import
logging
import
re
import
re
from
datetime
import
datetime
from
django.contrib.auth.models
import
User
,
Group
from
django.contrib.auth.models
import
User
,
Group
from
django.contrib.messages
import
warning
from
django.contrib.messages
import
warning
...
@@ -163,6 +164,7 @@ class VmDetailView(CheckedDetailView):
...
@@ -163,6 +164,7 @@ class VmDetailView(CheckedDetailView):
'to_remove'
:
self
.
__remove_tag
,
'to_remove'
:
self
.
__remove_tag
,
'port'
:
self
.
__add_port
,
'port'
:
self
.
__add_port
,
'new_network_vlan'
:
self
.
__new_network
,
'new_network_vlan'
:
self
.
__new_network
,
'save_as'
:
self
.
__save_as
,
}
}
for
k
,
v
in
options
.
iteritems
():
for
k
,
v
in
options
.
iteritems
():
...
@@ -316,6 +318,21 @@ class VmDetailView(CheckedDetailView):
...
@@ -316,6 +318,21 @@ class VmDetailView(CheckedDetailView):
return
redirect
(
"
%
s#network"
%
reverse_lazy
(
return
redirect
(
"
%
s#network"
%
reverse_lazy
(
"dashboard.views.detail"
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
}))
"dashboard.views.detail"
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
}))
def
__save_as
(
self
,
request
):
self
.
object
=
self
.
get_object
()
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
date
=
datetime
.
now
()
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M"
)
new_name
=
"Saved from
%
s (#
%
d) at
%
s"
%
(
self
.
object
.
name
,
self
.
object
.
pk
,
date
)
template
=
self
.
object
.
save_as_template
(
new_name
)
messages
.
success
(
request
,
_
(
"Instance succesfully saved as template, "
"please rename it!"
))
return
redirect
(
reverse_lazy
(
"dashboard.views.template-detail"
,
kwargs
=
{
'pk'
:
template
.
pk
}))
class
NodeDetailView
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
DetailView
):
class
NodeDetailView
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
DetailView
):
template_name
=
"dashboard/node-detail.html"
template_name
=
"dashboard/node-detail.html"
...
...
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