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
f211db99
authored
Mar 16, 2015
by
Bach Dániel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'datastore-bugs' into 'master'
Fix datastore bugs
✅
Closes #387 See merge request !304
parents
a1392d3a
47d1eca5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
7 deletions
+92
-7
circle/dashboard/forms.py
+5
-0
circle/dashboard/static/dashboard/dashboard.less
+6
-0
circle/dashboard/tables.py
+2
-1
circle/dashboard/templates/dashboard/storage/detail.html
+29
-0
circle/dashboard/views/storage.py
+50
-6
No files found.
circle/dashboard/forms.py
View file @
f211db99
...
@@ -1607,11 +1607,16 @@ class DataStoreForm(ModelForm):
...
@@ -1607,11 +1607,16 @@ class DataStoreForm(ModelForm):
class
DiskForm
(
ModelForm
):
class
DiskForm
(
ModelForm
):
created
=
forms
.
DateTimeField
()
modified
=
forms
.
DateTimeField
()
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
DiskForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
DiskForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
for
k
,
v
in
self
.
fields
.
iteritems
():
for
k
,
v
in
self
.
fields
.
iteritems
():
v
.
widget
.
attrs
[
'readonly'
]
=
True
v
.
widget
.
attrs
[
'readonly'
]
=
True
self
.
fields
[
'created'
]
.
initial
=
self
.
instance
.
created
self
.
fields
[
'modified'
]
.
initial
=
self
.
instance
.
modified
class
Meta
:
class
Meta
:
model
=
Disk
model
=
Disk
circle/dashboard/static/dashboard/dashboard.less
View file @
f211db99
...
@@ -1271,3 +1271,9 @@ textarea[name="new_members"] {
...
@@ -1271,3 +1271,9 @@ textarea[name="new_members"] {
background: #f9f9f9;
background: #f9f9f9;
margin-top: 20px;
margin-top: 20px;
}
}
#disk-list-table {
td:last-child {
text-align: center;
}
}
circle/dashboard/tables.py
View file @
f211db99
...
@@ -350,4 +350,5 @@ class DiskListTable(Table):
...
@@ -350,4 +350,5 @@ class DiskListTable(Table):
fields
=
(
"pk"
,
"appliance"
,
"filename"
,
"size"
,
"is_ready"
)
fields
=
(
"pk"
,
"appliance"
,
"filename"
,
"size"
,
"is_ready"
)
prefix
=
"disk-"
prefix
=
"disk-"
order_by
=
(
"-pk"
,
)
order_by
=
(
"-pk"
,
)
per_page
=
65536
per_page
=
15
empty_text
=
_
(
"No disk found."
)
circle/dashboard/templates/dashboard/storage/detail.html
View file @
f211db99
...
@@ -52,7 +52,9 @@
...
@@ -52,7 +52,9 @@
<small>
{% trans "image files without disk object in the database" %}
</small>
<small>
{% trans "image files without disk object in the database" %}
</small>
</h3>
</h3>
{% for o in orphan_disks %}
{% for o in orphan_disks %}
<p>
{{ o }}
{{ o }}
</p>
{% empty %}
{% empty %}
{% trans "None" %}
{% trans "None" %}
{% endfor %}
{% endfor %}
...
@@ -68,6 +70,33 @@
...
@@ -68,6 +70,33 @@
<h3
class=
"no-margin"
><i
class=
"fa fa-file"
></i>
{% trans "Disks" %}
</h3>
<h3
class=
"no-margin"
><i
class=
"fa fa-file"
></i>
{% trans "Disks" %}
</h3>
</div>
</div>
<div
class=
"panel-body"
>
<div
class=
"panel-body"
>
<div
class=
"row"
>
<div
class=
"col-md-9"
>
<ul
class=
"nav nav-pills"
style=
"margin: 5px 0 20px 0;"
>
<li
class=
"disabled"
><a
href=
"#"
>
{% trans "Filter by type" %}
</a></li>
<li
{%
if
not
request
.
GET
.
filter
%}
class=
"active"
{%
endif
%}
>
<a
href=
"{{ request.path }}?s={{ request.GET.s }}"
>
{% trans "ALL" %}
</a>
</li>
{% for f in filter_names %}
<li
{%
if
request
.
GET
.
filter =
=
f
.
0
%}
class=
"active"
{%
endif
%}
>
<a
href=
"?filter={{ f.0 }}&s={{ request.GET.s }}"
>
{{ f.1|capfirst }}
</a>
</li>
{% endfor %}
</ul>
</div>
<div
class=
"col-md-3"
>
<form
action=
""
method=
"GET"
id=
"network-host-list-form"
>
<div
class=
"input-group"
>
<input
type=
"text"
name=
"s"
class=
"form-control"
value=
"{{ request.GET.s }}"
placeholder=
"{% trans "
Search
..."
%}"
/>
<span
class=
"input-group-btn"
>
<button
class=
"btn btn-primary"
><i
class=
"fa fa-search"
></i></button>
</span>
<input
type=
"hidden"
name=
"filter"
value=
"{{ request.GET.filter }}"
/>
</div>
</form>
</div>
</div>
<!-- .row -->
<div
class=
"table-responsive"
>
<div
class=
"table-responsive"
>
{% render_table disk_table %}
{% render_table disk_table %}
</div>
</div>
...
...
circle/dashboard/views/storage.py
View file @
f211db99
...
@@ -16,13 +16,16 @@
...
@@ -16,13 +16,16 @@
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from
__future__
import
unicode_literals
,
absolute_import
from
__future__
import
unicode_literals
,
absolute_import
from
django.contrib
import
messages
from
django.views.generic
import
UpdateView
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.db.models
import
Q
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.views.generic
import
UpdateView
from
sizefield.utils
import
filesizeformat
from
braces.views
import
SuperuserRequiredMixin
from
braces.views
import
SuperuserRequiredMixin
from
sizefield.utils
import
filesizeformat
from
common.models
import
WorkerNotFound
from
storage.models
import
DataStore
,
Disk
from
storage.models
import
DataStore
,
Disk
from
..tables
import
DiskListTable
from
..tables
import
DiskListTable
from
..forms
import
DataStoreForm
,
DiskForm
from
..forms
import
DataStoreForm
,
DiskForm
...
@@ -40,15 +43,53 @@ class StorageDetail(SuperuserRequiredMixin, UpdateView):
...
@@ -40,15 +43,53 @@ class StorageDetail(SuperuserRequiredMixin, UpdateView):
context
=
super
(
StorageDetail
,
self
)
.
get_context_data
(
**
kwargs
)
context
=
super
(
StorageDetail
,
self
)
.
get_context_data
(
**
kwargs
)
ds
=
self
.
get_object
()
ds
=
self
.
get_object
()
try
:
context
[
'stats'
]
=
self
.
_get_stats
()
context
[
'stats'
]
=
self
.
_get_stats
()
context
[
'missing_disks'
]
=
ds
.
get_missing_disks
()
context
[
'missing_disks'
]
=
ds
.
get_missing_disks
()
context
[
'orphan_disks'
]
=
ds
.
get_orphan_disks
()
context
[
'orphan_disks'
]
=
ds
.
get_orphan_disks
()
qs
=
Disk
.
objects
.
filter
(
datastore
=
ds
,
destroyed
=
None
)
except
WorkerNotFound
:
messages
.
error
(
self
.
request
,
_
(
"The DataStore is offline."
))
context
[
'disk_table'
]
=
DiskListTable
(
context
[
'disk_table'
]
=
DiskListTable
(
qs
,
request
=
self
.
request
,
self
.
get_table_data
(),
request
=
self
.
request
,
template
=
"django_tables2/table_no_page.html"
)
template
=
"django_tables2/with_pagination.html"
)
context
[
'filter_names'
]
=
(
(
'vm'
,
_
(
"virtual machine"
)),
(
'template'
,
_
(
"template"
)),
(
'none'
,
_
(
"none"
)),
)
return
context
return
context
def
get_table_data
(
self
):
ds
=
self
.
get_object
()
qs
=
Disk
.
objects
.
filter
(
datastore
=
ds
,
destroyed
=
None
)
filter_name
=
self
.
request
.
GET
.
get
(
"filter"
)
search
=
self
.
request
.
GET
.
get
(
"s"
)
filter_queries
=
{
'vm'
:
{
'instance_set__isnull'
:
False
,
},
'template'
:
{
'template_set__isnull'
:
False
,
},
'none'
:
{
'template_set__isnull'
:
True
,
'instance_set__isnull'
:
True
,
}
}
if
filter_name
:
qs
=
qs
.
filter
(
**
filter_queries
.
get
(
filter_name
,
{}))
if
search
:
search
=
search
.
strip
()
qs
=
qs
.
filter
(
Q
(
name__icontains
=
search
)
|
Q
(
filename__icontains
=
search
))
return
qs
def
_get_stats
(
self
):
def
_get_stats
(
self
):
stats
=
self
.
object
.
get_statistics
()
stats
=
self
.
object
.
get_statistics
()
free_space
=
int
(
stats
[
'free_space'
])
free_space
=
int
(
stats
[
'free_space'
])
...
@@ -72,3 +113,6 @@ class DiskDetail(SuperuserRequiredMixin, UpdateView):
...
@@ -72,3 +113,6 @@ class DiskDetail(SuperuserRequiredMixin, UpdateView):
model
=
Disk
model
=
Disk
form_class
=
DiskForm
form_class
=
DiskForm
template_name
=
"dashboard/storage/disk.html"
template_name
=
"dashboard/storage/disk.html"
def
form_valid
(
self
,
form
):
pass
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