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
e2a771fd
authored
Apr 18, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: reimplement VmMigrateView as OperationView
parent
052cee88
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
41 deletions
+35
-41
circle/dashboard/templates/dashboard/_vm-migrate.html
+14
-6
circle/dashboard/views.py
+21
-35
No files found.
circle/dashboard/templates/dashboard/_vm-migrate.html
View file @
e2a771fd
{% extends "dashboard/operate.html" %}
{% load i18n %}
{% load i18n %}
{% load sizefieldtags %}
{% load sizefieldtags %}
<form
method=
"POST"
action=
"{% url "
dashboard
.
views
.
vm-migrate
"
pk=
vm.pk
%}"
>
{% block question %}
{% csrf_token %}
<p>
<ul
id=
"vm-migrate-node-list"
>
{% blocktrans with obj=object op=op.name %}
{% with current=vm.node.pk selected=vm.select_node.pk %}
Choose a compute node to migrate {{obj}} to.
{% endblocktrans %}
</p>
<p
class=
"text-info"
>
{{op.name}}: {{op.description}}
</p>
{% endblock %}
{% block formfields %}
<ul
id=
"vm-migrate-node-list"
class=
"list-unstyled"
>
{% with current=object.node.pk selected=object.select_node.pk %}
{% for n in nodes %}
{% for n in nodes %}
<li
class=
"panel panel-default"
><div
class=
"panel-body"
>
<li
class=
"panel panel-default"
><div
class=
"panel-body"
>
<label
for=
"migrate-to-{{n.pk}}"
>
<label
for=
"migrate-to-{{n.pk}}"
>
...
@@ -22,5 +31,4 @@
...
@@ -22,5 +31,4 @@
{% endfor %}
{% endfor %}
{% endwith %}
{% endwith %}
</ul>
</ul>
<button
type=
"submit"
class=
"btn btn-primary btn-sm"
><i
class=
"icon-truck"
></i>
Migrate
</button>
{% endblock %}
</form>
circle/dashboard/views.py
View file @
e2a771fd
...
@@ -483,10 +483,30 @@ class VmOperationView(OperationView):
...
@@ -483,10 +483,30 @@ class VmOperationView(OperationView):
model
=
Instance
model
=
Instance
class
VmMigrateView
(
VmOperationView
):
op
=
'migrate'
icon
=
'truck'
template_name
=
'dashboard/_vm-migrate.html'
def
get_context_data
(
self
,
**
kwargs
):
ctx
=
super
(
VmOperationView
,
self
)
.
get_context_data
(
**
kwargs
)
ctx
[
'nodes'
]
=
[
n
for
n
in
Node
.
objects
.
filter
(
enabled
=
True
)
if
n
.
state
==
"ONLINE"
]
return
ctx
def
post
(
self
,
request
,
extra
=
None
,
*
args
,
**
kwargs
):
node
=
self
.
request
.
POST
.
get
(
"node"
)
if
node
:
node
=
get_object_or_404
(
Node
,
pk
=
node
)
extra
[
"to_node"
]
=
node
return
super
(
VmMigrateView
,
self
)
.
post
(
request
,
extra
,
*
args
,
**
kwargs
)
vm_ops
=
{
vm_ops
=
{
'reset'
:
VmOperationView
.
factory
(
op
=
'reset'
,
icon
=
'bolt'
),
'reset'
:
VmOperationView
.
factory
(
op
=
'reset'
,
icon
=
'bolt'
),
'deploy'
:
VmOperationView
.
factory
(
op
=
'deploy'
,
icon
=
'play'
),
'deploy'
:
VmOperationView
.
factory
(
op
=
'deploy'
,
icon
=
'play'
),
'migrate'
:
Vm
OperationView
.
factory
(
op
=
'migrate'
,
icon
=
'truck'
)
,
'migrate'
:
Vm
MigrateView
,
'reboot'
:
VmOperationView
.
factory
(
op
=
'reboot'
,
icon
=
'refresh'
),
'reboot'
:
VmOperationView
.
factory
(
op
=
'reboot'
,
icon
=
'refresh'
),
'shut_off'
:
VmOperationView
.
factory
(
op
=
'shut_off'
,
icon
=
'ban-circle'
),
'shut_off'
:
VmOperationView
.
factory
(
op
=
'shut_off'
,
icon
=
'ban-circle'
),
'shutdown'
:
VmOperationView
.
factory
(
op
=
'shutdown'
,
icon
=
'off'
),
'shutdown'
:
VmOperationView
.
factory
(
op
=
'shutdown'
,
icon
=
'off'
),
...
@@ -2047,40 +2067,6 @@ class NotificationView(LoginRequiredMixin, TemplateView):
...
@@ -2047,40 +2067,6 @@ class NotificationView(LoginRequiredMixin, TemplateView):
return
response
return
response
class
VmMigrateView
(
SuperuserRequiredMixin
,
TemplateView
):
def
get_template_names
(
self
):
if
self
.
request
.
is_ajax
():
return
[
'dashboard/modal-wrapper.html'
]
else
:
return
[
'dashboard/nojs-wrapper.html'
]
def
get
(
self
,
request
,
form
=
None
,
*
args
,
**
kwargs
):
context
=
self
.
get_context_data
(
**
kwargs
)
vm
=
Instance
.
objects
.
get
(
pk
=
kwargs
[
'pk'
])
context
.
update
({
'template'
:
'dashboard/_vm-migrate.html'
,
'box_title'
:
_
(
'Migrate
%(name)
s'
%
{
'name'
:
vm
.
name
}),
'ajax_title'
:
True
,
'vm'
:
vm
,
'nodes'
:
[
n
for
n
in
Node
.
objects
.
filter
(
enabled
=
True
)
if
n
.
state
==
"ONLINE"
]
})
return
self
.
render_to_response
(
context
)
def
post
(
self
,
*
args
,
**
kwargs
):
node
=
self
.
request
.
POST
.
get
(
"node"
)
vm
=
Instance
.
objects
.
get
(
pk
=
kwargs
[
'pk'
])
if
node
:
node
=
Node
.
objects
.
get
(
pk
=
node
)
vm
.
migrate
.
async
(
to_node
=
node
,
user
=
self
.
request
.
user
)
else
:
messages
.
error
(
self
.
request
,
_
(
"You didn't select a node!"
))
return
redirect
(
"
%
s#activity"
%
vm
.
get_absolute_url
())
def
circle_login
(
request
):
def
circle_login
(
request
):
authentication_form
=
CircleAuthenticationForm
authentication_form
=
CircleAuthenticationForm
extra_context
=
{
extra_context
=
{
...
...
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