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
fa87d987
authored
Feb 27, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: get console token at time of tab loading
closes #87
parent
bde85e58
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
20 deletions
+46
-20
circle/dashboard/templates/dashboard/vm-detail/console.html
+19
-9
circle/dashboard/urls.py
+3
-1
circle/dashboard/views.py
+24
-10
No files found.
circle/dashboard/templates/dashboard/vm-detail/console.html
View file @
fa87d987
...
...
@@ -63,15 +63,25 @@
port
=
window
.
location
.
port
==
""
?
"443"
:
window
.
location
.
port
;
}
password
=
''
;
path
=
'vnc/?d={{ vnc_url }}'
;
$
(
'#_console .btn-toolbar button'
).
attr
(
'disabled'
,
true
);
$
(
'#noVNC_status'
).
html
(
'Retreiving authorization token.'
);
$
.
get
(
'{{ vnc_url }}'
,
function
(
data
)
{
if
(
data
.
indexOf
(
'vnc'
)
!=
0
)
{
$
(
'#noVNC_status'
).
html
(
'No authorization token received.'
);
}
else
{
rfb
=
new
RFB
({
'target'
:
$D
(
'noVNC_canvas'
),
'encrypt'
:
(
window
.
location
.
protocol
===
"https:"
),
'true_color'
:
true
,
'local_cursor'
:
true
,
'shared'
:
true
,
'view_only'
:
false
,
'updateState'
:
updateState
});
rfb
.
connect
(
host
,
port
,
password
,
data
);
}
}).
fail
(
function
(){
$
(
'#noVNC_status'
).
html
(
"Can't connect to console."
);
});
rfb
=
new
RFB
({
'target'
:
$D
(
'noVNC_canvas'
),
'encrypt'
:
(
window
.
location
.
protocol
===
"https:"
),
'true_color'
:
true
,
'local_cursor'
:
true
,
'shared'
:
true
,
'view_only'
:
false
,
'updateState'
:
updateState
});
rfb
.
connect
(
host
,
port
,
password
,
path
);
});
</script>
circle/dashboard/urls.py
View file @
fa87d987
...
...
@@ -9,7 +9,7 @@ from .views import (
FavouriteView
,
NodeStatus
,
GroupList
,
TemplateDelete
,
LeaseDelete
,
VmGraphView
,
TemplateAclUpdateView
,
GroupDetailView
,
GroupDelete
,
GroupAclUpdateView
,
GroupUserDelete
,
NotificationView
,
NodeGraphView
,
VmMigrateView
,
VmMigrateView
,
VmDetailVncTokenView
,
)
urlpatterns
=
patterns
(
...
...
@@ -37,6 +37,8 @@ urlpatterns = patterns(
name
=
'dashboard.views.remove-port'
),
url
(
r'^vm/(?P<pk>\d+)/$'
,
VmDetailView
.
as_view
(),
name
=
'dashboard.views.detail'
),
url
(
r'^vm/(?P<pk>\d+)/vnctoken/$'
,
VmDetailVncTokenView
.
as_view
(),
name
=
'dashboard.views.detail-vnc'
),
url
(
r'^vm/(?P<pk>\d+)/acl/$'
,
AclUpdateView
.
as_view
(
model
=
Instance
),
name
=
'dashboard.views.vm-acl'
),
url
(
r'^vm/(?P<pk>\d+)/tx/$'
,
TransferOwnershipView
.
as_view
(),
...
...
circle/dashboard/views.py
View file @
fa87d987
...
...
@@ -148,6 +148,25 @@ class CheckedDetailView(LoginRequiredMixin, DetailView):
return
context
class
VmDetailVncTokenView
(
CheckedDetailView
):
template_name
=
"dashboard/vm-detail.html"
model
=
Instance
def
get
(
self
,
request
,
**
kwargs
):
self
.
object
=
self
.
get_object
()
if
not
self
.
object
.
has_level
(
request
.
user
,
'operator'
):
raise
PermissionDenied
()
if
self
.
object
.
node
:
port
=
self
.
object
.
vnc_port
host
=
str
(
self
.
object
.
node
.
host
.
ipv4
)
value
=
signing
.
dumps
({
'host'
:
host
,
'port'
:
port
},
key
=
getenv
(
"PROXY_SECRET"
,
'asdasd'
)),
return
HttpResponse
(
'vnc/?d=
%
s'
%
value
)
else
:
raise
Http404
()
class
VmDetailView
(
CheckedDetailView
):
template_name
=
"dashboard/vm-detail.html"
model
=
Instance
...
...
@@ -155,16 +174,11 @@ class VmDetailView(CheckedDetailView):
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
VmDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
instance
=
context
[
'instance'
]
if
instance
.
node
:
port
=
instance
.
vnc_port
host
=
str
(
instance
.
node
.
host
.
ipv4
)
value
=
signing
.
dumps
({
'host'
:
host
,
'port'
:
port
},
key
=
getenv
(
"PROXY_SECRET"
,
'asdasd'
)),
context
.
update
({
'graphite_enabled'
:
VmGraphView
.
get_graphite_url
()
is
not
None
,
'vnc_url'
:
'
%
s'
%
value
})
context
.
update
({
'graphite_enabled'
:
VmGraphView
.
get_graphite_url
()
is
not
None
,
'vnc_url'
:
reverse_lazy
(
"dashboard.views.detail-vnc"
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
})
})
# activity data
ia
=
InstanceActivity
.
objects
.
filter
(
...
...
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