Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1d1ab1ea
authored
Aug 14, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: mass migration
parent
79ddd6fb
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
142 additions
and
24 deletions
+142
-24
circle/dashboard/static/dashboard/vm-list.js
+13
-4
circle/dashboard/templates/dashboard/_vm-mass-migrate.html
+29
-0
circle/dashboard/templates/dashboard/mass-operate.html
+16
-15
circle/dashboard/templates/dashboard/vm-list.html
+53
-2
circle/dashboard/views.py
+29
-2
circle/vm/models/instance.py
+2
-1
No files found.
circle/dashboard/static/dashboard/vm-list.js
View file @
1d1ab1ea
...
@@ -114,7 +114,7 @@ $(function() {
...
@@ -114,7 +114,7 @@ $(function() {
$
(
"body"
).
on
(
"click"
,
"#op-form-send"
,
function
()
{
$
(
"body"
).
on
(
"click"
,
"#op-form-send"
,
function
()
{
var
url
=
$
(
this
).
closest
(
"form"
).
prop
(
"action"
);
var
url
=
$
(
this
).
closest
(
"form"
).
prop
(
"action"
);
$
(
this
).
find
(
"i"
).
prop
(
"class"
,
"fa fa-spinner fa-spin"
);
$
(
this
).
find
(
"i"
).
prop
(
"class"
,
"fa fa-
fw fa-
spinner fa-spin"
);
$
.
ajax
({
$
.
ajax
({
url
:
url
,
url
:
url
,
...
@@ -177,7 +177,8 @@ $(function() {
...
@@ -177,7 +177,8 @@ $(function() {
function
checkStatusUpdate
()
{
function
checkStatusUpdate
()
{
if
(
$
(
"#vm-list-table tbody td.state i"
).
hasClass
(
"fa-spin"
))
{
icons
=
$
(
"#vm-list-table tbody td.state i"
);
if
(
icons
.
hasClass
(
"fa-spin"
)
||
icons
.
hasClass
(
"migrating-icon"
))
{
return
true
;
return
true
;
}
}
}
}
...
@@ -194,12 +195,20 @@ function updateStatuses(runs) {
...
@@ -194,12 +195,20 @@ function updateStatuses(runs) {
if
(
vm
in
result
)
{
if
(
vm
in
result
)
{
if
(
result
[
vm
].
in_status_change
)
{
if
(
result
[
vm
].
in_status_change
)
{
if
(
!
status_icon
.
hasClass
(
"fa-spin"
))
{
if
(
!
status_icon
.
hasClass
(
"fa-spin"
))
{
status_icon
.
prop
(
"class"
,
"fa fa-spinner fa-spin"
);
status_icon
.
prop
(
"class"
,
"fa fa-fw fa-spinner fa-spin"
);
}
}
else
if
(
result
[
vm
].
status
==
"MIGRATING"
)
{
if
(
!
status_icon
.
hasClass
(
"migrating-icon"
))
{
status_icon
.
prop
(
"class"
,
"fa fa-fw "
+
result
[
vm
].
icon
+
" migrating-icon"
);
}
}
}
else
{
}
else
{
status_icon
.
prop
(
"class"
,
"fa "
+
result
[
vm
].
icon
);
status_icon
.
prop
(
"class"
,
"fa
fa-fw
"
+
result
[
vm
].
icon
);
}
}
status_text
.
text
(
result
[
vm
].
status
);
status_text
.
text
(
result
[
vm
].
status
);
if
(
"node"
in
result
[
vm
])
{
$
(
this
).
find
(
".node"
).
text
(
result
[
vm
].
node
);
}
}
else
{
}
else
{
$
(
this
).
remove
();
$
(
this
).
remove
();
}
}
...
...
circle/dashboard/templates/dashboard/_vm-mass-migrate.html
0 → 100644
View file @
1d1ab1ea
{% extends "dashboard/mass-operate.html" %}
{% load i18n %}
{% load sizefieldtags %}
{% block question %}
<p>
{% blocktrans with op=op.name %}
Choose a compute node to migrate the selected VMs to.
{% endblocktrans %}
</p>
<p
class=
"text-info"
>
{{op.name}}: {{op.description}}
</p>
{% endblock %}
{% block formfields %}
<ul
id=
"vm-migrate-node-list"
class=
"list-unstyled"
>
{% for n in nodes %}
<li
class=
"panel panel-default"
><div
class=
"panel-body"
>
<label
for=
"migrate-to-{{n.pk}}"
>
<strong>
{{ n }}
</strong>
</label>
<input
id=
"migrate-to-{{n.pk}}"
type=
"radio"
name=
"node"
value=
"{{ n.pk }}"
style=
"float: right;"
checked=
"checked"
>
<span
class=
"vm-migrate-node-property"
>
{% trans "CPU load" %}: {{ n.cpu_usage }}
</span>
<span
class=
"vm-migrate-node-property"
>
{% trans "RAM usage" %}: {{ n.byte_ram_usage|filesize }}/{{ n.ram_size|filesize }}
</span>
<div
style=
"clear: both;"
></div>
</div></li>
{% endfor %}
</ul>
<hr
/>
{% endblock %}
circle/dashboard/templates/dashboard/mass-operate.html
View file @
1d1ab1ea
...
@@ -10,26 +10,27 @@ Do you want to perform the following operation: <strong>{{op}}</strong>?
...
@@ -10,26 +10,27 @@ Do you want to perform the following operation: <strong>{{op}}</strong>?
<p
class=
"text-info"
>
{{op.description}}
</p>
<p
class=
"text-info"
>
{{op.description}}
</p>
{% endblock %}
{% endblock %}
<form
method=
"POST"
action=
"{{url}}"
>
{% csrf_token %}
<form
method=
"POST"
action=
"{{url}}"
>
{% csrf_token %}
{% for i in instances
%}
{% block formfields %}{% endblock
%}
<div
class=
"panel panel-default mass-op-panel"
>
{% for i in instances %}
<i
class=
"fa {{ i.get_status_icon }} fa-fw"
></i
>
<div
class=
"panel panel-default mass-op-panel"
>
{{ i.name }} ({{ i.pk }})
<i
class=
"fa {{ i.get_status_icon }} fa-fw"
></i>
<div
style=
"float: right;"
title=
"{{ i.disabled }}"
>
{{ i.name }} ({{ i.pk }})
<i
class=
"fa status-icon
<div
style=
"float: right;"
title=
"{{ i.disabled }}"
>
{% if i.disabled %}fa-minus-square minus{% else %}fa-check-square check{% endif %}"
>
<i
class=
"fa status-icon
</i
>
{% if i.disabled %}fa-minus-square minus{% else %}fa-check-square check{% endif %}"
>
</
div
>
</
i
>
</div>
</div>
<input
type=
"checkbox"
name=
"vm"
value=
"{{ i.pk }}"
{%
if
not
i
.
disabled
%}
checked
{%
endif
%}
</div>
style=
"display: none;"
/>
<input
type=
"checkbox"
name=
"vm"
value=
"{{ i.pk }}"
{%
if
not
i
.
disabled
%}
checked
{%
endif
%}
{% endfor %}
style=
"display: none;"
/>
{% endfor %}
<div
class=
"pull-right"
>
<div
class=
"pull-right"
>
<a
class=
"btn btn-default"
href=
"{% url "
dashboard
.
views
.
vm-list
"
%}"
<a
class=
"btn btn-default"
href=
"{% url "
dashboard
.
views
.
vm-list
"
%}"
data-dismiss=
"modal"
>
{% trans "Cancel" %}
</a>
data-dismiss=
"modal"
>
{% trans "Cancel" %}
</a>
<button
class=
"btn btn-{{ opview.effect }}"
type=
"submit"
id=
"op-form-send"
>
<button
class=
"btn btn-{{ opview.effect }}"
type=
"submit"
id=
"op-form-send"
>
{% if opview.icon %}
<i
class=
"fa
fa-{{opview.icon}}"
></i>
{% endif %}{{ opview.name|capfirst }}
{% if opview.icon %}
<i
class=
"fa fa-fw
fa-{{opview.icon}}"
></i>
{% endif %}{{ opview.name|capfirst }}
</button>
</button>
</div>
</div>
</form>
</form>
...
...
circle/dashboard/templates/dashboard/vm-list.html
View file @
1d1ab1ea
...
@@ -66,7 +66,7 @@
...
@@ -66,7 +66,7 @@
<td
class=
"pk"
><div
id=
"vm-{{i.pk}}"
>
{{i.pk}}
</div>
</td>
<td
class=
"pk"
><div
id=
"vm-{{i.pk}}"
>
{{i.pk}}
</div>
</td>
<td
class=
"name"
><a
class=
"real-link"
href=
"{% url "
dashboard
.
views
.
detail
"
i
.
pk
%}"
>
{{ i.name }}
</a>
</td>
<td
class=
"name"
><a
class=
"real-link"
href=
"{% url "
dashboard
.
views
.
detail
"
i
.
pk
%}"
>
{{ i.name }}
</a>
</td>
<td
class=
"state"
>
<td
class=
"state"
>
<i
class=
"fa
<i
class=
"fa
fa-fw
{% if i.is_in_status_change %}
{% if i.is_in_status_change %}
fa-spin fa-spinner
fa-spin fa-spinner
{% else %}
{% else %}
...
@@ -77,7 +77,9 @@
...
@@ -77,7 +77,9 @@
{% include "dashboard/_display-name.html" with user=i.owner show_org=True %}
{% include "dashboard/_display-name.html" with user=i.owner show_org=True %}
</td>
</td>
{% if user.is_superuser %}
{% if user.is_superuser %}
<td
data-sort-value=
"{{ i.node.normalized_name }}"
>
{{ i.node.name|default:"-" }}
</td>
<td
class=
"node "
data-sort-value=
"{{ i.node.normalized_name }}"
>
{{ i.node.name|default:"-" }}
</td>
{% endif %}
{% endif %}
</tr>
</tr>
{% empty %}
{% empty %}
...
@@ -109,4 +111,53 @@
...
@@ -109,4 +111,53 @@
{% block extra_js %}
{% block extra_js %}
<script
src=
"{{ STATIC_URL}}dashboard/vm-list.js"
></script>
<script
src=
"{{ STATIC_URL}}dashboard/vm-list.js"
></script>
<script
src=
"{{ STATIC_URL}}dashboard/js/stupidtable.min.js"
></script>
<script
src=
"{{ STATIC_URL}}dashboard/js/stupidtable.min.js"
></script>
<style>
#vm-list-table
.migrating-icon
{
-webkit-animation
:
passing
2s
linear
infinite
;
animation
:
passing
2s
linear
infinite
;
}
@-webkit-keyframes
passing
{
0
%
{
-webkit-transform
:
translateX
(
50%
);
transform
:
translateX
(
50%
);
opacity
:
0
;
}
50
%
{
-webkit-transform
:
translateX
(
0%
);
transform
:
translateX
(
0%
);
opacity
:
1
;
}
100
%
{
-webkit-transform
:
translateX
(
-50%
);
transform
:
translateX
(
-50%
);
opacity
:
0
;
}
}
@keyframes
passing
{
0
%
{
-webkit-transform
:
translateX
(
50%
);
-ms-transform
:
translateX
(
50%
);
transform
:
translateX
(
50%
);
opacity
:
0
;
}
50
%
{
-webkit-transform
:
translateX
(
0%
);
-ms-transform
:
translateX
(
0%
);
transform
:
translateX
(
0%
);
opacity
:
1
;
}
100
%
{
-webkit-transform
:
translateX
(
-50%
);
-ms-transform
:
translateX
(
-50%
);
transform
:
translateX
(
-50%
);
opacity
:
0
;
}
}
</style>
{% endblock %}
{% endblock %}
circle/dashboard/views.py
View file @
1d1ab1ea
...
@@ -1034,14 +1034,16 @@ class MassOperationView(OperationView):
...
@@ -1034,14 +1034,16 @@ class MassOperationView(OperationView):
vms
.
append
(
i
)
vms
.
append
(
i
)
return
vms
return
vms
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
def
post
(
self
,
request
,
extra
=
None
,
*
args
,
**
kwargs
):
if
extra
is
None
:
extra
=
{}
user
=
self
.
request
.
user
user
=
self
.
request
.
user
vms
=
request
.
POST
.
getlist
(
"vm"
)
vms
=
request
.
POST
.
getlist
(
"vm"
)
instances
=
Instance
.
objects
.
filter
(
pk__in
=
vms
)
instances
=
Instance
.
objects
.
filter
(
pk__in
=
vms
)
for
i
in
instances
:
for
i
in
instances
:
try
:
try
:
op
=
self
.
_op_checks
(
i
,
user
)
op
=
self
.
_op_checks
(
i
,
user
)
op
.
async
(
user
=
user
)
op
.
async
(
user
=
user
,
**
extra
)
except
HumanReadableException
as
e
:
except
HumanReadableException
as
e
:
e
.
send_message
(
request
)
e
.
send_message
(
request
)
except
Exception
as
e
:
except
Exception
as
e
:
...
@@ -1067,6 +1069,28 @@ class MassOperationView(OperationView):
...
@@ -1067,6 +1069,28 @@ class MassOperationView(OperationView):
return
op
return
op
class
MassMigrationView
(
MassOperationView
):
template_name
=
'dashboard/_vm-mass-migrate.html'
icon
=
"info"
op
=
"migrate"
icon
=
"truck"
def
get_context_data
(
self
,
**
kwargs
):
ctx
=
super
(
MassMigrationView
,
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
):
if
extra
is
None
:
extra
=
{}
node
=
self
.
request
.
POST
.
get
(
"node"
)
if
node
:
node
=
get_object_or_404
(
Node
,
pk
=
node
)
extra
[
"to_node"
]
=
node
return
super
(
MassMigrationView
,
self
)
.
post
(
request
,
extra
,
*
args
,
**
kwargs
)
vm_mass_ops
=
OrderedDict
([
vm_mass_ops
=
OrderedDict
([
(
'deploy'
,
MassOperationView
.
factory
(
(
'deploy'
,
MassOperationView
.
factory
(
op
=
'deploy'
,
icon
=
'play'
,
effect
=
'success'
)),
op
=
'deploy'
,
icon
=
'play'
,
effect
=
'success'
)),
...
@@ -1074,6 +1098,7 @@ vm_mass_ops = OrderedDict([
...
@@ -1074,6 +1098,7 @@ vm_mass_ops = OrderedDict([
op
=
'wake_up'
,
icon
=
'sun-o'
,
effect
=
'success'
)),
op
=
'wake_up'
,
icon
=
'sun-o'
,
effect
=
'success'
)),
(
'sleep'
,
MassOperationView
.
factory
(
(
'sleep'
,
MassOperationView
.
factory
(
op
=
'sleep'
,
icon
=
'moon-o'
,
effect
=
'info'
)),
op
=
'sleep'
,
icon
=
'moon-o'
,
effect
=
'info'
)),
(
'migrate'
,
MassMigrationView
),
(
'destroy'
,
MassOperationView
.
factory
(
(
'destroy'
,
MassOperationView
.
factory
(
op
=
'destroy'
,
icon
=
'times'
,
effect
=
'danger'
)),
op
=
'destroy'
,
icon
=
'times'
,
effect
=
'danger'
)),
])
])
...
@@ -1671,6 +1696,8 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
...
@@ -1671,6 +1696,8 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
'icon'
:
i
.
get_status_icon
(),
'icon'
:
i
.
get_status_icon
(),
'in_status_change'
:
i
.
is_in_status_change
(),
'in_status_change'
:
i
.
is_in_status_change
(),
}
}
if
self
.
request
.
user
.
is_superuser
:
statuses
[
i
.
pk
][
'node'
]
=
i
.
node
.
name
if
i
.
node
else
"-"
return
HttpResponse
(
json
.
dumps
(
statuses
),
return
HttpResponse
(
json
.
dumps
(
statuses
),
content_type
=
"application/json"
)
content_type
=
"application/json"
)
else
:
else
:
...
...
circle/vm/models/instance.py
View file @
1d1ab1ea
...
@@ -938,7 +938,8 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
...
@@ -938,7 +938,8 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
'ERROR'
:
'fa-warning'
,
'ERROR'
:
'fa-warning'
,
'PENDING'
:
'fa-rocket'
,
'PENDING'
:
'fa-rocket'
,
'DESTROYED'
:
'fa-trash-o'
,
'DESTROYED'
:
'fa-trash-o'
,
'MIGRATING'
:
'fa-truck'
}
.
get
(
self
.
status
,
'fa-question'
)
'MIGRATING'
:
'fa-truck migrating-icon'
}
.
get
(
self
.
status
,
'fa-question'
)
def
get_activities
(
self
,
user
=
None
):
def
get_activities
(
self
,
user
=
None
):
acts
=
(
self
.
activity_log
.
filter
(
parent
=
None
)
.
acts
=
(
self
.
activity_log
.
filter
(
parent
=
None
)
.
...
...
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