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
478df358
authored
Jul 29, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: working vm change resources
parent
10db4cc6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
61 deletions
+30
-61
circle/dashboard/static/dashboard/dashboard.css
+5
-1
circle/dashboard/static/dashboard/vm-details.js
+9
-0
circle/dashboard/templates/dashboard/vm-detail/resources.html
+6
-58
circle/dashboard/views.py
+1
-0
circle/vm/models/instance.py
+1
-1
circle/vm/operations.py
+8
-1
No files found.
circle/dashboard/static/dashboard/dashboard.css
View file @
478df358
...
@@ -720,6 +720,10 @@ textarea[name="list-new-namelist"] {
...
@@ -720,6 +720,10 @@ textarea[name="list-new-namelist"] {
margin
:
20px
0
0
10px
;
margin
:
20px
0
0
10px
;
}
}
.vm-resources-sliders
.row
{
#vm-details-resources-form
{
margin-top
:
15px
;
}
#vm-details-resources-form
.row
{
margin-bottom
:
15px
;
margin-bottom
:
15px
;
}
}
circle/dashboard/static/dashboard/vm-details.js
View file @
478df358
...
@@ -27,6 +27,15 @@ $(function() {
...
@@ -27,6 +27,15 @@ $(function() {
/* save resources */
/* save resources */
$
(
'#vm-details-resources-save'
).
click
(
function
()
{
$
(
'#vm-details-resources-save'
).
click
(
function
()
{
var
error
=
false
;
$
(
".cpu-count-input, .ram-input"
).
each
(
function
()
{
if
(
!
$
(
this
)[
0
].
checkValidity
())
{
error
=
true
;
}
});
if
(
error
)
return
true
;
$
(
'i.fa-floppy-o'
,
this
).
removeClass
(
"fa-floppy-o"
).
addClass
(
"fa-refresh fa-spin"
);
$
(
'i.fa-floppy-o'
,
this
).
removeClass
(
"fa-floppy-o"
).
addClass
(
"fa-refresh fa-spin"
);
var
vm
=
$
(
this
).
data
(
"vm"
);
var
vm
=
$
(
this
).
data
(
"vm"
);
$
.
ajax
({
$
.
ajax
({
...
...
circle/dashboard/templates/dashboard/vm-detail/resources.html
View file @
478df358
...
@@ -2,11 +2,8 @@
...
@@ -2,11 +2,8 @@
{% load sizefieldtags %}
{% load sizefieldtags %}
{% load crispy_forms_tags %}
{% load crispy_forms_tags %}
<hr
/>
<form
method=
"POST"
action=
"{{ op.resources_change.get_url }}"
id=
"vm-details-resources-form"
>
<div
class=
"vm-resources-sliders"
>
{% csrf_token %}
<form
method=
"POST"
action=
"{{ op.resources_change.get_url }}"
>
{% csrf_token %}
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-sm-3"
style=
"font-weight: bold;"
>
<div
class=
"col-sm-3"
style=
"font-weight: bold;"
>
<i
class=
"fa fa-trophy"
></i>
{% trans "CPU priority" %}
<i
class=
"fa fa-trophy"
></i>
{% trans "CPU priority" %}
...
@@ -66,69 +63,20 @@
...
@@ -66,69 +63,20 @@
</div>
</div>
</div>
</div>
{% if can_change_resources %}
{% if can_change_resources %}
<button
type=
"submit"
class=
"btn btn-success btn-sm change-resources-button"
id=
"vm-details-resources-savea"
<button
type=
"submit"
class=
"btn btn-success btn-sm change-resources-button"
data-vm=
"{{ instance.pk }}"
id=
"vm-details-resources-save"
data-vm=
"{{ instance.pk }}"
{%
if
not
op
.
resources_change
%}
disabled
{%
endif
%}
>
{%
if
op
.
resources_change
.
disabled
%}
disabled
{%
endif
%}
>
<i
class=
"fa fa-floppy-o"
></i>
{% trans "Save resources" %}
<i
class=
"fa fa-floppy-o"
></i>
{% trans "Save resources" %}
</button>
</button>
<span
class=
"change-resources-help"
<span
class=
"change-resources-help"
{%
if
op
.
resources_change
%}
style=
"display: none;"
{%
endif
%}
{%
if
not
op
.
resources_change
.
disabled
%}
style=
"display: none;"
{%
endif
%}
>
{% trans "Stop your VM to change resources." %}
</span>
>
{% trans "Stop your VM to change resources." %}
</span>
{% endif %}
{% endif %}
</form>
</form>
</div>
<hr
/>
<hr
/>
<form
id=
"vm-details-resources-form"
method=
"POST"
action=
""
>
{% csrf_token %}
<p
class=
"row"
>
<div
class=
"col-sm-3"
>
<label
for=
"vm-cpu-priority-slider"
><i
class=
"fa fa-trophy"
></i>
{% trans "CPU priority" %}
</label>
</div>
<div
class=
"col-sm-9"
>
<input
name=
"cpu-priority"
type=
"text"
id=
"vm-cpu-priority-slider"
class=
"vm-slider"
value=
"{{ instance.priority }}"
data-slider-min=
"0"
data-slider-max=
"100"
data-slider-step=
"1"
data-slider-value=
"{{ instance.priority }}"
data-slider-orientation=
"horizontal"
data-slider-handle=
"square"
data-slider-tooltip=
"hide"
/>
</div>
</p>
<p
class=
"row"
>
<div
class=
"col-sm-3"
>
<label
for=
"cpu-count-slider"
><i
class=
"fa fa-cogs"
></i>
{% trans "CPU count" %}
</label>
</div>
<div
class=
"col-sm-9"
>
<input
name=
"cpu-count"
type=
"text"
id=
"vm-cpu-count-slider"
class=
"vm-slider"
value=
" {{ instance.num_cores }}"
data-slider-min=
"0"
data-slider-max=
"8"
data-slider-step=
"1"
data-slider-value=
"{{ instance.num_cores }}"
data-slider-orientation=
"horizontal"
data-slider-handle=
"square"
data-slider-tooltip=
"hide"
/>
</div>
</p>
<p
class=
"row"
>
<div
class=
"col-sm-3"
>
<label
for=
"ram-slider"
><i
class=
"fa fa-ticket"
></i>
{% trans "RAM amount" %}
</label>
</div>
<div
class=
"col-sm-9"
>
<input
name=
"ram-size"
type=
"text"
id=
"vm-ram-size-slider"
class=
"vm-slider"
value=
"{{ instance.ram_size }}"
data-slider-min=
"128"
data-slider-max=
"4096"
data-slider-step=
"128"
data-slider-value=
"{{ instance.ram_size }}"
data-slider-orientation=
"horizontal"
data-slider-handle=
"square"
data-slider-tooltip=
"hide"
/>
MiB
</div>
</p>
{% if can_change_resources %}
<p
class=
"row"
>
<div
class=
"col-sm-12"
>
<button
type=
"submit"
class=
"btn btn-success btn-sm enabled-when-stopped"
id=
"vm-details-resources-save"
data-vm=
"{{ instance.pk }}"
{%
if
not
op
.
resources_change
%}
disabled
{%
endif
%}
>
<i
class=
"fa fa-floppy-o"
></i>
{% trans "Save resources" %}
</button>
<span
class=
"hide-when-stopped"
{%
if
op
.
resources_change
%}
style=
"display: none;"
{%
endif
%}
>
{% trans "Stop your VM to change resources." %}
</span>
</div>
</p>
{% endif %}
</form>
<hr
/>
<div
class=
"row"
id=
"vm-details-resources-disk"
>
<div
class=
"row"
id=
"vm-details-resources-disk"
>
<div
class=
"col-sm-11"
>
<div
class=
"col-sm-11"
>
...
...
circle/dashboard/views.py
View file @
478df358
...
@@ -751,6 +751,7 @@ class VmResourcesChangeView(VmOperationView):
...
@@ -751,6 +751,7 @@ class VmResourcesChangeView(VmOperationView):
op
=
'resources_change'
op
=
'resources_change'
icon
=
"save"
icon
=
"save"
show_in_toolbar
=
False
show_in_toolbar
=
False
wait_for_result
=
0.5
def
post
(
self
,
request
,
extra
=
None
,
*
args
,
**
kwargs
):
def
post
(
self
,
request
,
extra
=
None
,
*
args
,
**
kwargs
):
if
extra
is
None
:
if
extra
is
None
:
...
...
circle/vm/models/instance.py
View file @
478df358
...
@@ -956,7 +956,7 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
...
@@ -956,7 +956,7 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
for
a
in
acts
:
for
a
in
acts
:
if
(
latest
==
a
.
activity_code
and
if
(
latest
==
a
.
activity_code
and
merged_acts
[
-
1
]
.
result
==
a
.
result
and
merged_acts
[
-
1
]
.
result
_data
==
a
.
result_data
and
a
.
finished
and
merged_acts
[
-
1
]
.
finished
and
a
.
finished
and
merged_acts
[
-
1
]
.
finished
and
a
.
user
==
merged_acts
[
-
1
]
.
user
and
a
.
user
==
merged_acts
[
-
1
]
.
user
and
(
merged_acts
[
-
1
]
.
finished
-
a
.
finished
)
.
days
<
7
and
(
merged_acts
[
-
1
]
.
finished
-
a
.
finished
)
.
days
<
7
and
...
...
circle/vm/operations.py
View file @
478df358
...
@@ -868,7 +868,8 @@ class ResourcesOperation(InstanceOperation):
...
@@ -868,7 +868,8 @@ class ResourcesOperation(InstanceOperation):
if
self
.
instance
.
status
not
in
[
"STOPPED"
,
"PENDING"
]:
if
self
.
instance
.
status
not
in
[
"STOPPED"
,
"PENDING"
]:
raise
self
.
instance
.
WrongStateError
(
self
.
instance
)
raise
self
.
instance
.
WrongStateError
(
self
.
instance
)
def
_operation
(
self
,
user
,
num_cores
,
ram_size
,
max_ram_size
,
priority
):
def
_operation
(
self
,
user
,
activity
,
num_cores
,
ram_size
,
max_ram_size
,
priority
):
self
.
instance
.
num_cores
=
num_cores
self
.
instance
.
num_cores
=
num_cores
self
.
instance
.
ram_size
=
ram_size
self
.
instance
.
ram_size
=
ram_size
...
@@ -878,6 +879,12 @@ class ResourcesOperation(InstanceOperation):
...
@@ -878,6 +879,12 @@ class ResourcesOperation(InstanceOperation):
self
.
instance
.
full_clean
()
self
.
instance
.
full_clean
()
self
.
instance
.
save
()
self
.
instance
.
save
()
activity
.
result
=
create_readable
(
ugettext_noop
(
"Priority:
%(priority)
s, Num cores:
%(num_cores)
s, "
"Ram size:
%(ram_size)
s"
),
priority
=
priority
,
num_cores
=
num_cores
,
ram_size
=
ram_size
)
register_operation
(
ResourcesOperation
)
register_operation
(
ResourcesOperation
)
...
...
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