Add console support
Change-Id: I0b845d8d2ac9bee30676b1d6e01609c71ffeae48
This commit is contained in:
parent
55cb393e1d
commit
0e4b38ffaf
@ -203,3 +203,13 @@ def flavor_get(request, flavor_id):
|
||||
"""
|
||||
flavor_manager = moganclient(request).flavor
|
||||
return flavor_manager.get(flavor_id)
|
||||
|
||||
|
||||
def console_get(request, server_id):
|
||||
"""Get serial console for a server.
|
||||
|
||||
:param request: HTTP request.
|
||||
:param server_id: The uuid of the server.
|
||||
"""
|
||||
server_manager = moganclient(request).server
|
||||
return server_manager.get_serial_console(server_id)
|
||||
|
@ -15,8 +15,11 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import tabs
|
||||
|
||||
from mogan_ui.api import mogan
|
||||
|
||||
|
||||
class OverviewTab(tabs.Tab):
|
||||
name = _("Overview")
|
||||
@ -29,7 +32,25 @@ class OverviewTab(tabs.Tab):
|
||||
"is_superuser": request.user.is_superuser}
|
||||
|
||||
|
||||
class ConsoleTab(tabs.Tab):
|
||||
name = _("Console")
|
||||
slug = "console"
|
||||
template_name = "project/servers/_detail_console.html"
|
||||
preload = False
|
||||
|
||||
def get_context_data(self, request):
|
||||
server = self.tab_group.kwargs['server']
|
||||
console_url = None
|
||||
try:
|
||||
console = mogan.console_get(request, server.uuid)
|
||||
console_url = console.console['url']
|
||||
except Exception:
|
||||
exceptions.handle(request, ignore=True, force_log=True)
|
||||
|
||||
return {'console_url': console_url, 'server_id': server.uuid}
|
||||
|
||||
|
||||
class ServerDetailTabs(tabs.DetailTabsGroup):
|
||||
slug = "server_details"
|
||||
tabs = (OverviewTab,)
|
||||
tabs = (OverviewTab, ConsoleTab)
|
||||
sticky = True
|
||||
|
@ -0,0 +1,26 @@
|
||||
{% load i18n %}
|
||||
|
||||
<h3>{% trans "Server Console" %}</h3>
|
||||
{% if console_url %}
|
||||
<p class='alert alert-info'>
|
||||
{% blocktrans %}If console is not responding to keyboard input: click the grey status bar below.{% endblocktrans %}
|
||||
<a href="{{ console_url }}" style="text-decoration: underline">{% trans "Click here to show only console" %}</a><br />
|
||||
{% trans "To exit the fullscreen mode, click the browser's back button." %}</p>
|
||||
<iframe id="console_embed" src="{{ console_url }}" style="width:100%;height:100%"></iframe>
|
||||
<script type="text/javascript">
|
||||
var fix_height = function() {
|
||||
$('iframe#console_embed').css({ height: $(document).height() + 'px' });
|
||||
};
|
||||
// there are two code paths to this particular block; handle them both
|
||||
if (typeof($) != 'undefined') {
|
||||
$(document).ready(fix_height);
|
||||
} else {
|
||||
addHorizonLoadEvent(fix_height);
|
||||
}
|
||||
</script>
|
||||
{% else %}
|
||||
<script type="text/javascript">
|
||||
horizon.toast.add('error', '{% blocktrans %}Console is currently unavailable.{% endblocktrans %}');
|
||||
</script>
|
||||
<div class="well">{% blocktrans %}Unable to load console. Please reload page to try again.{% endblocktrans %}</div>
|
||||
{% endif %}
|
@ -118,8 +118,6 @@ class SetServerDetailsAction(workflows.Action):
|
||||
flavor_list.sort()
|
||||
if not flavor_list:
|
||||
flavor_list.insert(0, ("", _("No flavors found")))
|
||||
elif len(flavor_list) > 1:
|
||||
flavor_list.insert(0, ("", _("Select Flavor")))
|
||||
return flavor_list
|
||||
|
||||
def populate_availability_zone_choices(self, request, context):
|
||||
|
Loading…
Reference in New Issue
Block a user