Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b27573f6
authored
Aug 12, 2016
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add refresh credential button
parent
ef1332c6
Pipeline
#173
passed with stage
in 0 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
11 deletions
+31
-11
circle/dashboard/templates/dashboard/storage/detail.html
+5
-0
circle/dashboard/urls.py
+4
-1
circle/dashboard/views/storage.py
+15
-10
circle/vm/models/node.py
+7
-0
No files found.
circle/dashboard/templates/dashboard/storage/detail.html
View file @
b27573f6
...
...
@@ -18,6 +18,11 @@
{% include "dashboard/storage/form_chunk.html" %}
<fieldset>
<input
type=
"submit"
value=
"{% trans "
Save
"
%}"
class=
"btn btn-primary"
>
{% if object.type == "ceph_block" %}
<a
class=
"btn btn-success pull-right"
href=
"{% url "
dashboard
.
views
.
storage-refresh_credential
"
pk=
object.pk
%}"
>
<i
class=
"fa fa-key"
></i>
{% trans "Refresh credential on all node" %}
</a>
{% endif %}
</fieldset>
</form>
</div>
<!-- .panel-body -->
...
...
circle/dashboard/urls.py
View file @
b27573f6
...
...
@@ -54,7 +54,7 @@ from .views import (
NodeActivityView
,
UserList
,
StorageDetail
,
StorageList
,
StorageChoose
,
StorageCreate
,
DiskDetail
,
StorageDelete
,
StorageRestore
,
StorageDelete
,
StorageRestore
,
StorageRefreshCredential
,
MessageList
,
MessageDetail
,
MessageCreate
,
MessageDelete
,
)
from
.views.vm
import
vm_ops
,
vm_mass_ops
...
...
@@ -250,6 +250,9 @@ urlpatterns = patterns(
name
=
"dashboard.views.storage-delete"
),
url
(
r"^storage/restore/(?P<pk>\d+)/$"
,
StorageRestore
.
as_view
(),
name
=
"dashboard.views.storage-restore"
),
url
(
r'^storage/(?P<pk>\d+)/refresh_credential/$'
,
StorageRefreshCredential
.
as_view
(),
name
=
'dashboard.views.storage-refresh_credential'
),
url
(
r'^disk/(?P<pk>\d+)/$'
,
DiskDetail
.
as_view
(),
name
=
"dashboard.views.disk-detail"
),
...
...
circle/dashboard/views/storage.py
View file @
b27573f6
...
...
@@ -23,7 +23,7 @@ from django.core.urlresolvers import reverse, reverse_lazy
from
django.db.models
import
Q
from
django.utils.translation
import
ugettext_lazy
as
_
,
ugettext
from
django.views.generic
import
(
UpdateView
,
TemplateView
,
CreateView
,
DeleteView
UpdateView
,
TemplateView
,
CreateView
,
DeleteView
,
DetailView
)
from
django.contrib.messages.views
import
SuccessMessageMixin
from
django.shortcuts
import
redirect
...
...
@@ -288,15 +288,8 @@ class StorageDetail(SuperuserRequiredMixin, UpdateView):
changed
=
(
self
.
object
.
type
==
"ceph_block"
and
self
.
object
.
ceph_user_changed
)
if
changed
:
try
:
nodes
=
Node
.
objects
.
all
()
for
node
in
nodes
:
if
node
.
get_online
():
node
.
refresh_credential
(
user
=
self
.
request
.
user
,
username
=
self
.
object
.
ceph_user
)
except
Exception
as
e
:
messages
.
error
(
self
.
request
,
unicode
(
e
))
Node
.
refresh_crendential_on_all
(
self
.
request
.
user
,
self
.
object
.
ceph_user
)
return
response
...
...
@@ -378,6 +371,18 @@ class StorageRestore(SuperuserRequiredMixin, UpdateView):
kwargs
=
{
"pk"
:
ds
.
id
})
class
StorageRefreshCredential
(
SuperuserRequiredMixin
,
DetailView
):
model
=
DataStore
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
if
self
.
get_object
()
.
type
==
'ceph_block'
:
Node
.
refresh_crendential_on_all
(
self
.
request
.
user
,
self
.
get_object
()
.
ceph_user
)
return
redirect
(
'dashboard.views.storage-detail'
,
pk
=
self
.
get_object
()
.
pk
)
class
DiskDetail
(
SuperuserRequiredMixin
,
UpdateView
):
model
=
Disk
form_class
=
DiskForm
...
...
circle/vm/models/node.py
View file @
b27573f6
...
...
@@ -460,3 +460,10 @@ class Node(OperatedMixin, TimeStampedModel):
@property
def
metric_prefix
(
self
):
return
'circle.
%
s'
%
self
.
host
.
hostname
@classmethod
def
refresh_crendential_on_all
(
cls
,
user
,
ceph_user
):
nodes
=
cls
.
objects
.
all
()
for
node
in
nodes
:
if
node
.
get_online
():
node
.
refresh_credential
.
async
(
user
=
user
,
username
=
ceph_user
)
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