示例#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(
                          'steer:engine: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(
                          'steer:engine: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('steer: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('steer:syspanel:instances:index', tenant_id)
示例#3
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(
                'steer:engine: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(
            'steer:engine: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('steer:engine:instances_and_volumes:instances:vnc',
                    args=[INSTANCE_ID]))

        self.assertRedirectsNoFollow(
            res, reverse('steer:engine:instances_and_volumes:instances:index'))
示例#5
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('steer:engine:instances_and_volumes:instances:vnc',
                            args=[INSTANCE_ID]))

        self.assertRedirectsNoFollow(res,
                reverse('steer:engine:instances_and_volumes:instances:index'))
示例#6
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('steer:engine:instances_and_volumes:instances:vnc',
                    args=[INSTANCE_ID]))

        self.assertRedirectsNoFollow(res,
                                     CONSOLE_OUTPUT + '&title=serverName(1)')
示例#7
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('steer:engine:instances_and_volumes:instances:vnc',
                            args=[INSTANCE_ID]))

        self.assertRedirectsNoFollow(res,
                CONSOLE_OUTPUT + '&title=serverName(1)')
示例#8
0
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(
                          'steer:engine:instances_and_volumes:instances:index')
示例#9
0
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(
            'steer:engine:instances_and_volumes:instances:index')
示例#10
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('steer: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('steer:syspanel:instances:index', tenant_id)