コード例 #1
0
def detail(request, instance_id):
    tenant_id = request.user.tenant_id
    try:
        instance = api.server_get(request, instance_id)
        volumes = api.volume_instance_list(request, instance_id)
        try:
            console = api.console_create(request, instance_id, 'vnc')
            vnc_url = "%s&title=%s(%s)" % (console.output, instance.name,
                                           instance_id)
        except api_exceptions.ApiException, e:
            LOG.exception(
                _('ApiException while fetching instance vnc \
                           connection'))
            messages.error(
                request,
                _('Unable to get vnc console for instance %(inst)s: %(msg)s') %
                {
                    "inst": instance_id,
                    "msg": e.message
                })
            return shortcuts.redirect(
                'horizon:nova:instances_and_volumes:instances:index')
    except api_exceptions.ApiException, e:
        LOG.exception(_('ApiException while fetching instance info'))
        messages.error(
            request,
            _('Unable to get information for instance %(inst)s: %(msg)s') % {
                "inst": instance_id,
                "msg": e.message
            })
        return shortcuts.redirect(
            'horizon:nova:instances_and_volumes:instances:index')
コード例 #2
0
def detail(request, instance_id):
    try:
        instance = api.server_get(request, instance_id)
        try:
            console = api.console_create(request, instance_id, 'vnc')
            vnc_url = "%s&title=%s(%s)" % (console.output, instance.name,
                                           instance_id)
        except api_exceptions.ApiException, e:
            LOG.exception('ApiException while fetching instance vnc \
                           connection')
            messages.error(
                request,
                _('Unable to get vnc console for instance %(inst)s: %(message)s'
                  ) % {
                      "inst": instance_id,
                      "message": e.message
                  })
            return redirect('horizon:syspanel:instances:index', tenant_id)
    except api_exceptions.ApiException, e:
        LOG.exception('ApiException while fetching instance info')
        messages.error(
            request,
            _('Unable to get information for instance %(inst)s: %(message)s') %
            {
                "inst": instance_id,
                "message": e.message
            })
        return redirect('horizon:syspanel:instances:index', tenant_id)
コード例 #3
0
ファイル: views.py プロジェクト: karansingh/horizon-xcp
def detail(request, instance_id):
    tenant_id = request.user.tenant_id
    try:
        instance = api.server_get(request, instance_id)
        volumes = api.volume_instance_list(request, instance_id)
	LOG.debug(("KDS: instance-name: %s instance-ip: %s" %(instance.name, instance.ip)))
        try:
            console = api.console_create(request, instance_id, 'vnc')
            vnc_url = "%s&title=%s(%s)" % (console.output,
                                           instance.name,
                                           instance_id)
        except api_exceptions.ApiException, e:
            LOG.exception(_('ApiException while fetching instance vnc \
                           connection'))
            messages.error(request,
                _('Unable to get vnc console for instance %(inst)s: %(msg)s') %
                {"inst": instance_id, "msg": e.message})
            return shortcuts.redirect(
                          'horizon:nova:instances_and_volumes:instances:index')
    except api_exceptions.ApiException, e:
        LOG.exception(_('ApiException while fetching instance info'))
        messages.error(request,
            _('Unable to get information for instance %(inst)s: %(msg)s') %
            {"inst": instance_id, "msg": e.message})
        return shortcuts.redirect(
                          'horizon:nova:instances_and_volumes:instances:index')
コード例 #4
0
    def test_instance_vnc_exception(self):
        INSTANCE_ID = self.servers[0].id

        exception = api_exceptions.ApiException('apiException',
                                                message='apiException')

        self.mox.StubOutWithMock(api, 'console_create')
        api.console_create(IsA(http.HttpRequest), unicode(INSTANCE_ID),
                           'vnc').AndRaise(exception)

        self.mox.ReplayAll()

        res = self.client.get(
            reverse('horizon:nova:instances_and_volumes:instances:vnc',
                    args=[INSTANCE_ID]))

        self.assertRedirectsNoFollow(
            res, reverse('horizon:nova:instances_and_volumes:instances:index'))
コード例 #5
0
ファイル: tests.py プロジェクト: BillTheBest/horizon
    def test_instance_vnc_exception(self):
        INSTANCE_ID = self.servers[0].id

        exception = api_exceptions.ApiException('apiException',
                                                message='apiException')

        self.mox.StubOutWithMock(api, 'console_create')
        api.console_create(IsA(http.HttpRequest),
                           unicode(INSTANCE_ID),
                           'vnc').AndRaise(exception)

        self.mox.ReplayAll()

        res = self.client.get(reverse('horizon:nova:instances:vnc',
                                      args=[INSTANCE_ID]))

        self.assertRedirectsNoFollow(res,
                                     reverse('horizon:nova:instances:index'))
コード例 #6
0
    def test_instance_console(self):
        CONSOLE_OUTPUT = 'output'
        INSTANCE_ID = self.servers[0].id

        console_mock = self.mox.CreateMock(api.Console)
        console_mock.output = CONSOLE_OUTPUT

        self.mox.StubOutWithMock(api, 'console_create')
        api.console_create(IgnoreArg(), unicode(INSTANCE_ID),
                           IgnoreArg()).AndReturn(console_mock)

        self.mox.ReplayAll()

        res = self.client.get(
            reverse('horizon:nova:instances_and_volumes:instances:console',
                    args=[INSTANCE_ID]))

        self.assertIsInstance(res, http.HttpResponse)
        self.assertContains(res, CONSOLE_OUTPUT)
コード例 #7
0
ファイル: tests.py プロジェクト: BillTheBest/horizon
    def test_instance_console(self):
        CONSOLE_OUTPUT = 'output'
        INSTANCE_ID = self.servers[0].id

        console_mock = self.mox.CreateMock(api.Console)
        console_mock.output = CONSOLE_OUTPUT

        self.mox.StubOutWithMock(api, 'console_create')
        api.console_create(IgnoreArg(),
                           unicode(INSTANCE_ID),
                           IgnoreArg()).AndReturn(console_mock)

        self.mox.ReplayAll()

        res = self.client.get(reverse('horizon:nova:instances:console',
                                      args=[INSTANCE_ID]))

        self.assertIsInstance(res, http.HttpResponse)
        self.assertContains(res, CONSOLE_OUTPUT)
コード例 #8
0
    def test_instance_console_exception(self):
        INSTANCE_ID = self.servers[0].id

        exception = api_exceptions.ApiException('apiException',
                                                message='apiException')

        self.mox.StubOutWithMock(api, 'console_create')
        api.console_create(IgnoreArg(), unicode(INSTANCE_ID),
                           IgnoreArg()).AndRaise(exception)

        self.mox.StubOutWithMock(messages, 'error')
        messages.error(IgnoreArg(), IsA(unicode))

        self.mox.ReplayAll()

        res = self.client.get(
            reverse('horizon:nova:instances_and_volumes:instances:console',
                    args=[INSTANCE_ID]))

        self.assertRedirectsNoFollow(
            res, reverse('horizon:nova:instances_and_volumes:instances:index'))
コード例 #9
0
ファイル: tests.py プロジェクト: BillTheBest/horizon
    def test_instance_console_exception(self):
        INSTANCE_ID = self.servers[0].id

        exception = api_exceptions.ApiException('apiException',
                                                message='apiException')

        self.mox.StubOutWithMock(api, 'console_create')
        api.console_create(IgnoreArg(),
                           unicode(INSTANCE_ID),
                           IgnoreArg()).AndRaise(exception)

        self.mox.StubOutWithMock(messages, 'error')
        messages.error(IgnoreArg(), IsA(unicode))

        self.mox.ReplayAll()

        res = self.client.get(reverse('horizon:nova:instances:console',
                                      args=[INSTANCE_ID]))

        self.assertRedirectsNoFollow(res,
                                     reverse('horizon:nova:instances:index'))
コード例 #10
0
    def test_instance_vnc(self):
        INSTANCE_ID = self.servers[0].id
        CONSOLE_OUTPUT = '/vncserver'

        console_mock = self.mox.CreateMock(api.Console)
        console_mock.output = CONSOLE_OUTPUT

        self.mox.StubOutWithMock(api, 'console_create')
        self.mox.StubOutWithMock(api, 'server_get')
        api.server_get(IsA(http.HttpRequest),
                       str(self.servers[0].id)).AndReturn(self.servers[0])
        api.console_create(IgnoreArg(), unicode(INSTANCE_ID),
                           'vnc').AndReturn(console_mock)

        self.mox.ReplayAll()

        res = self.client.get(
            reverse('horizon:nova:instances_and_volumes:instances:vnc',
                    args=[INSTANCE_ID]))

        self.assertRedirectsNoFollow(res,
                                     CONSOLE_OUTPUT + '&title=serverName(1)')
コード例 #11
0
ファイル: views.py プロジェクト: BillTheBest/horizon
def vnc(request, instance_id):
    tenant_id = request.user.tenant_id
    try:
        console = api.console_create(request, instance_id, 'vnc')
        instance = api.server_get(request, instance_id)
        return shortcuts.redirect(console.output +
                ("&title=%s(%s)" % (instance.name, instance_id)))
    except api_exceptions.ApiException, e:
        LOG.exception(_('ApiException while fetching instance vnc connection'))
        messages.error(request,
            _('Unable to get vnc console for instance %(inst)s: %(message)s') %
            {"inst": instance_id, "message": e.message})
        return shortcuts.redirect('horizon:nova:instances:index')
コード例 #12
0
ファイル: tests.py プロジェクト: BillTheBest/horizon
    def test_instance_vnc(self):
        INSTANCE_ID = self.servers[0].id
        CONSOLE_OUTPUT = '/vncserver'

        console_mock = self.mox.CreateMock(api.Console)
        console_mock.output = CONSOLE_OUTPUT

        self.mox.StubOutWithMock(api, 'console_create')
        self.mox.StubOutWithMock(api, 'server_get')
        api.server_get(IsA(http.HttpRequest),
                       str(self.servers[0].id)).AndReturn(self.servers[0])
        api.console_create(IgnoreArg(),
                           unicode(INSTANCE_ID),
                           'vnc').AndReturn(console_mock)

        self.mox.ReplayAll()

        res = self.client.get(reverse('horizon:nova:instances:vnc',
                                      args=[INSTANCE_ID]))

        self.assertRedirectsNoFollow(res,
                CONSOLE_OUTPUT + '&title=serverName(1)')
コード例 #13
0
ファイル: views.py プロジェクト: ehazlett/horizon
def vnc(request, instance_id):
    tenant_id = request.user.tenant_id
    try:
        console = api.console_create(request, instance_id, 'vnc')
        instance = api.server_get(request, instance_id)
        return shortcuts.redirect(console.output +
                ("&title=%s(%s)" % (instance.name, instance_id)))
    except api_exceptions.ApiException, e:
        LOG.exception(_('ApiException while fetching instance vnc connection'))
        messages.error(request,
            _('Unable to get vnc console for instance %(inst)s: %(message)s') %
            {"inst": instance_id, "message": e.message})
        return shortcuts.redirect(
                          'horizon:nova:instances_and_volumes:instances:index')
コード例 #14
0
ファイル: views.py プロジェクト: BillTheBest/horizon
def console(request, instance_id):
    tenant_id = request.user.tenant_id
    try:
        # TODO(jakedahn): clean this up once the api supports tailing.
        length = request.GET.get('length', '')
        console = api.console_create(request, instance_id, 'text')
        response = http.HttpResponse(mimetype='text/plain')
        if length:
            response.write('\n'.join(console.output.split('\n')
                           [-int(length):]))
        else:
            response.write(console.output)
        response.flush()
        return response
    except api_exceptions.ApiException, e:
        LOG.exception(_('ApiException while fetching instance console'))
        messages.error(request,
                   _('Unable to get log for instance %(inst)s: %(msg)s') %
                    {"inst": instance_id, "msg": e.message})
        return shortcuts.redirect('horizon:nova:instances:index')
コード例 #15
0
ファイル: views.py プロジェクト: griddynamics/horizon
def detail(request, instance_id):
    try:
        instance = api.server_get(request, instance_id)
        try:
            console = api.console_create(request, instance_id, 'vnc')
            vnc_url = "%s&title=%s(%s)" % (console.output,
                                           instance.name,
                                           instance_id)
        except api_exceptions.ApiException, e:
            LOG.exception('ApiException while fetching instance vnc \
                           connection')
            messages.error(request,
            _('Unable to get vnc console for instance %(inst)s: %(message)s') %
            {"inst": instance_id, "message": e.message})
            return redirect('horizon:syspanel:instances:index', tenant_id)
    except api_exceptions.ApiException, e:
        LOG.exception('ApiException while fetching instance info')
        messages.error(request,
            _('Unable to get information for instance %(inst)s: %(message)s') %
            {"inst": instance_id, "message": e.message})
        return redirect('horizon:syspanel:instances:index', tenant_id)
コード例 #16
0
ファイル: views.py プロジェクト: ehazlett/horizon
def console(request, instance_id):
    tenant_id = request.user.tenant_id
    try:
        # TODO(jakedahn): clean this up once the api supports tailing.
        length = request.GET.get('length', '')
        console = api.console_create(request, instance_id, 'text')
        response = http.HttpResponse(mimetype='text/plain')
        if length:
            response.write('\n'.join(console.output.split('\n')
                           [-int(length):]))
        else:
            response.write(console.output)
        response.flush()
        return response
    except api_exceptions.ApiException, e:
        LOG.exception(_('ApiException while fetching instance console'))
        messages.error(request,
                   _('Unable to get log for instance %(inst)s: %(msg)s') %
                    {"inst": instance_id, "msg": e.message})
        return shortcuts.redirect(
                          'horizon:nova:instances_and_volumes:instances:index')