Esempio n. 1
0
def rdp(request, instance_id):
    try:
        instance = api.nova.server_get(request, instance_id)
        console_url = project_console.get_console(request, 'RDP', instance)[1]
        return shortcuts.redirect(console_url)
    except Exception:
        redirect = reverse("horizon:compute_user:vminstance2:index")
        msg = _('Unable to get RDP console for instance "%s".') % instance_id
        exceptions.handle(request, msg, redirect=redirect)
Esempio n. 2
0
    def get_context_data(self, request):
        instance = self.tab_group.kwargs['instance']
        console_type = getattr(settings, 'CONSOLE_TYPE', 'AUTO')
        console_url = None
        try:
            console_type, console_url = console.get_console(
                request, console_type, instance)
            # For serial console, the url is different from VNC, etc.
            # because it does not include params for title and token
            if console_type == "SERIAL":
                console_url = reverse('horizon:compute_user:vminstance2:serial',
                                      args=[instance.id])
        except exceptions.NotAvailable:
            exceptions.handle(request, ignore=True, force_log=True)

        return {'console_url': console_url, 'instance_id': instance.id,
                'console_type': console_type}
Esempio n. 3
0
 def get_context_data(self, **kwargs):
     context = super(SerialConsoleView, self).get_context_data(**kwargs)
     context['instance_id'] = self.kwargs['instance_id']
     instance = None
     try:
         instance = api.nova.server_get(self.request,
                                        self.kwargs['instance_id'])
     except Exception:
         context["error_message"] = _(
             "Cannot find instance %s.") % self.kwargs['instance_id']
         # name is unknown, so leave it blank for the window title
         # in full-screen mode, so only the instance id is shown.
         context['instance_name'] = ''
         return context
     context['instance_name'] = instance.name
     try:
         console_url = project_console.get_console(self.request,
                                                   "SERIAL", instance)[1]
         context["console_url"] = console_url
     except exceptions.NotAvailable:
         context["error_message"] = _(
             "Cannot get console for instance %s.") % self.kwargs[
             'instance_id']
     return context