Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
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
895d9a95
authored
Dec 10, 2017
by
falusi94
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify snapshot
dashboard, storage, vm: now snapshot handling does not have incorrect logic
parent
b1575ee5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
23 deletions
+47
-23
circle/dashboard/static/dashboard/dashboard.less
+0
-4
circle/dashboard/templates/dashboard/_disk-list-element.html
+12
-18
circle/storage/migrations/0004_disk_did_have_snapshot.py
+20
-0
circle/storage/models.py
+7
-1
circle/vm/operations.py
+8
-0
No files found.
circle/dashboard/static/dashboard/dashboard.less
View file @
895d9a95
...
...
@@ -1088,10 +1088,6 @@ textarea[name="new_members"] {
vertical-align: middle;
}
.disk-resize-btn {
margin-right: 5px;
}
#vm-migrate-node-list li {
cursor: pointer;
}
...
...
circle/dashboard/templates/dashboard/_disk-list-element.html
View file @
895d9a95
...
...
@@ -7,12 +7,10 @@
<span
class=
"operation-wrapper pull-right"
>
<div>
{% if op.create_snapshot %}
<a
href=
"{{ op.create_snapshot.get_url }}?disk={{d.pk}}"
class=
"btn btn-xs btn-{{ op.create_snapshot.effect }} operation disk-create_snapshot-btn
{% if op.create_snapshot.disabled %}disabled{% endif %}"
>
<i
class=
"fa fa-{{ op.create_snapshot.icon }} fa-fw-12"
></i>
{% trans "Snapshot" %}
</a>
{% if perms.view_snapshot and d.list_snapshots %}
<input
type=
"button"
class=
"btn btn-default btn-xs show-snapshot-btn"
data-toggle=
"collapse"
data-target=
"#snapshots-{{ d.pk }}"
value=
"{% trans "
Show
snapshots
"
%}"
/>
{% endif %}
{% if d.is_resizable %}
{% if op.resize_disk %}
...
...
@@ -26,10 +24,13 @@
<i
class=
"fa fa-arrows-alt fa-fw-12"
></i>
{% trans "Request resize" %}
</a>
{% endif %}
{% else %}
<small
class=
"btn-xs"
>
{% trans "Not resizable" %}
</small>
{% endif %}
{% if op.create_snapshot and not d.is_read_only and d.is_ready %}
<a
href=
"{{ op.create_snapshot.get_url }}?disk={{d.pk}}"
class=
"btn btn-xs btn-{{ op.create_snapshot.effect }} operation disk-create_snapshot-btn
{% if op.create_snapshot.disabled %}disabled{% endif %}"
>
<i
class=
"fa fa-{{ op.create_snapshot.icon }} fa-fw-12"
></i>
{% trans "Snapshot" %}
</a>
{% endif %}
{% if op.remove_disk %}
<a
href=
"{{ op.remove_disk.get_url }}?disk={{d.pk}}"
...
...
@@ -39,13 +40,6 @@
</a>
{% endif %}
</div>
<div
class=
"pull-right"
>
{% if perms.view_snapshot and d.list_snapshots %}
<input
type=
"button"
class=
"btn btn-default btn-xs show-snapshot-btn"
data-toggle=
"collapse"
data-target=
"#snapshots-{{ d.pk }}"
value=
"{% trans "
Show
snapshots
"
%}"
/>
{% endif %}
</div>
</span>
<br
/>
{% if request.user.is_superuser %}
...
...
@@ -53,7 +47,7 @@
<small>
{% trans "Bus" %}: {{ d.device_bus }}
</small><br
/>
{% endif %}
<div
style=
"clear: both;"
></div>
{% if perms.storage.view_snapshot %}
{% if perms.storage.view_snapshot
and d.list_snapshots
%}
<div
id=
"snapshots-{{ d.pk }}"
class=
"collapse out snapshot-list"
>
<table
class=
"table table-striped info-panel small snapshot-table"
>
{% for snap in d.list_snapshots %}
...
...
circle/storage/migrations/0004_disk_did_have_snapshot.py
0 → 100644
View file @
895d9a95
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-12-10 01:02
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'storage'
,
'0003_auto_20160826_1619'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'disk'
,
name
=
'did_have_snapshot'
,
field
=
models
.
BooleanField
(
default
=
False
),
),
]
circle/storage/models.py
View file @
895d9a95
...
...
@@ -141,6 +141,7 @@ class Disk(TimeStampedModel):
dev_num
=
CharField
(
default
=
'a'
,
max_length
=
1
,
verbose_name
=
_
(
"device number"
))
destroyed
=
DateTimeField
(
blank
=
True
,
default
=
None
,
null
=
True
)
did_have_snapshot
=
BooleanField
(
default
=
False
)
is_ready
=
BooleanField
(
default
=
False
)
...
...
@@ -575,4 +576,9 @@ class Disk(TimeStampedModel):
@property
def
is_resizable
(
self
):
return
self
.
type
in
(
'qcow2-norm'
,
'raw-rw'
,
'qcow2-snap'
,
)
return
(
self
.
type
in
(
'qcow2-norm'
,
'raw-rw'
,
'qcow2-snap'
,
)
and
not
self
.
did_have_snapshot
)
@property
def
is_read_only
(
self
):
return
not
self
.
type
in
(
'qcow2-norm'
,
'raw-rw'
,
)
circle/vm/operations.py
View file @
895d9a95
...
...
@@ -290,6 +290,7 @@ class RemoteSnapshotDiskOperation(InstanceOperation):
def
_operation
(
self
,
disk
,
**
kwargs
):
if
disk
:
self
.
disk
=
disk
if
not
disk
.
is_ready
:
raise
disk
.
DiskIsNotReady
(
disk
)
disk_desc
=
disk
.
get_disk_desc
()
...
...
@@ -316,6 +317,10 @@ class CreateSnapshotDiskOperation(RemoteSnapshotDiskOperation):
snap_name
=
'new snapshot'
return
[
snap_name
]
def
on_commit
(
self
,
activity
):
self
.
disk
.
did_have_snapshot
=
True
self
.
disk
.
save
()
def
get_activity_name
(
self
,
kwargs
):
return
create_readable
(
ugettext_noop
(
'Created snapshot
%(snap_name)
s'
...
...
@@ -389,6 +394,9 @@ class ResizeDiskOperation(RemoteInstanceOperation):
def
_operation
(
self
,
disk
,
size
):
if
not
disk
.
is_resizable
:
if
disk
.
did_have_snapshot
:
raise
HumanReadableException
.
create
(
ugettext_noop
(
'Disk already had snapshot, that is why not resizable.'
))
raise
HumanReadableException
.
create
(
ugettext_noop
(
'Disk type "
%(type)
s" is not resizable.'
),
type
=
disk
.
type
)
super
(
ResizeDiskOperation
,
self
)
.
_operation
(
disk
=
disk
,
size
=
size
)
...
...
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