Statistics
| Branch: | Tag: | Revision:

root / snf-cyclades-app / synnefo / ui / views.py @ 30096a2e

History | View | Annotate | Download (18.8 kB)

1
# Copyright 2011 GRNET S.A. All rights reserved.
2
#
3
# Redistribution and use in source and binary forms, with or
4
# without modification, are permitted provided that the following
5
# conditions are met:
6
#
7
#   1. Redistributions of source code must retain the above
8
#      copyright notice, this list of conditions and the following
9
#      disclaimer.
10
#
11
#   2. Redistributions in binary form must reproduce the above
12
#      copyright notice, this list of conditions and the following
13
#      disclaimer in the documentation and/or other materials
14
#      provided with the distribution.
15
#
16
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
# POSSIBILITY OF SUCH DAMAGE.
28
#
29
# The views and conclusions contained in the software and
30
# documentation are those of the authors and should not be
31
# interpreted as representing official policies, either expressed
32
# or implied, of GRNET S.A.
33
#
34

    
35
import os
36

    
37
from django.conf import settings
38
from django.utils.translation import gettext_lazy as _
39
from django.template import loader
40
from django.http import HttpResponse
41
from django.utils.translation import get_language
42
from django.utils import simplejson as json
43
from django.template.loader import render_to_string
44
from django.core.urlresolvers import reverse
45
from django.template import RequestContext
46

    
47
from synnefo.util.version import get_component_version
48

    
49
from snf_django.lib.astakos import get_user
50

    
51
SYNNEFO_JS_LIB_VERSION = get_component_version('app')
52

    
53
# api configuration
54
COMPUTE_API_URL = getattr(settings, 'COMPUTE_API_URL', '/api/v1.1')
55

    
56
# UI preferences settings
57
TIMEOUT = getattr(settings, "TIMEOUT", 10000)
58
UPDATE_INTERVAL = getattr(settings, "UI_UPDATE_INTERVAL", 5000)
59
CHANGES_SINCE_ALIGNMENT = getattr(settings, "UI_CHANGES_SINCE_ALIGNMENT", 0)
60
UPDATE_INTERVAL_INCREASE = getattr(settings, "UI_UPDATE_INTERVAL_INCREASE", 500)
61
UPDATE_INTERVAL_INCREASE_AFTER_CALLS_COUNT = \
62
    getattr(settings, "UI_UPDATE_INTERVAL_INCREASE_AFTER_CALLS_COUNT", 3)
63
UPDATE_INTERVAL_FAST = getattr(settings, "UI_UPDATE_INTERVAL_FAST", 2500)
64
UPDATE_INTERVAL_MAX = getattr(settings, "UI_UPDATE_INTERVAL_MAX", 10000)
65
QUOTAS_UPDATE_INTERVAL = getattr(settings, "UI_QUOTAS_UPDATE_INTERVAL", 10000)
66

    
67
# predefined values settings
68
VM_IMAGE_COMMON_METADATA = \
69
    getattr(settings, "UI_VM_IMAGE_COMMON_METADATA", ["OS", "users"])
70
SUGGESTED_FLAVORS_DEFAULT = {}
71
SUGGESTED_FLAVORS = getattr(settings, "VM_CREATE_SUGGESTED_FLAVORS",
72
                            SUGGESTED_FLAVORS_DEFAULT)
73
SUGGESTED_ROLES_DEFAULT = ["Database server", "File server", "Mail server",
74
                           "Web server", "Proxy"]
75
SUGGESTED_ROLES = getattr(settings, "VM_CREATE_SUGGESTED_ROLES",
76
                          SUGGESTED_ROLES_DEFAULT)
77
IMAGE_ICONS = settings.IMAGE_ICONS
78
IMAGE_DELETED_TITLE = \
79
    getattr(settings, 'UI_IMAGE_DELETED_TITLE', '(deleted)')
80
IMAGE_DELETED_SIZE_TITLE = \
81
    getattr(settings, 'UI_IMAGE_DELETED_SIZE_TITLE', '(none)')
82

    
83
SUPPORT_SSH_OS_LIST = getattr(settings, "UI_SUPPORT_SSH_OS_LIST",)
84
OS_CREATED_USERS = getattr(settings, "UI_OS_DEFAULT_USER_MAP")
85
LOGOUT_URL = getattr(settings, "UI_LOGOUT_URL", '/im/authenticate')
86
LOGIN_URL = getattr(settings, "UI_LOGIN_URL", '/im/login')
87
AUTH_COOKIE_NAME = getattr(settings, "UI_AUTH_COOKIE_NAME", 'synnefo_user')
88

    
89
# UI behaviour settings
90
DELAY_ON_BLUR = getattr(settings, "UI_DELAY_ON_BLUR", True)
91
UPDATE_HIDDEN_VIEWS = getattr(settings, "UI_UPDATE_HIDDEN_VIEWS", False)
92
HANDLE_WINDOW_EXCEPTIONS = \
93
    getattr(settings, "UI_HANDLE_WINDOW_EXCEPTIONS", True)
94
SKIP_TIMEOUTS = getattr(settings, "UI_SKIP_TIMEOUTS", 1)
95

    
96
# Additional settings
97
VM_NAME_TEMPLATE = getattr(settings, "VM_CREATE_NAME_TPL", "My {0} server")
98
VM_HOSTNAME_FORMAT = getattr(settings, "UI_VM_HOSTNAME_FORMAT",
99
                             'snf-%(id)s.vm.okeanos.grnet.gr')
100

    
101
if isinstance(VM_HOSTNAME_FORMAT, basestring):
102
    VM_HOSTNAME_FORMAT = VM_HOSTNAME_FORMAT % {'id': '{0}'}
103

    
104
MAX_SSH_KEYS_PER_USER = getattr(settings, "USERDATA_MAX_SSH_KEYS_PER_USER")
105
FLAVORS_DISK_TEMPLATES_INFO = \
106
    getattr(settings, "UI_FLAVORS_DISK_TEMPLATES_INFO", {})
107
SYSTEM_IMAGES_OWNERS = getattr(settings, "UI_SYSTEM_IMAGES_OWNERS", {})
108
CUSTOM_IMAGE_HELP_URL = getattr(settings, "UI_CUSTOM_IMAGE_HELP_URL", None)
109

    
110
# MEDIA PATHS
111
UI_MEDIA_URL = \
112
    getattr(settings, "UI_MEDIA_URL",
113
            "%ssnf-%s/" % (settings.MEDIA_URL, SYNNEFO_JS_LIB_VERSION))
114
UI_SYNNEFO_IMAGES_URL = \
115
    getattr(settings,
116
            "UI_SYNNEFO_IMAGES_URL", UI_MEDIA_URL + "images/")
117
UI_SYNNEFO_CSS_URL = \
118
    getattr(settings,
119
            "UI_SYNNEFO_CSS_URL", UI_MEDIA_URL + "css/")
120
UI_SYNNEFO_JS_URL = \
121
    getattr(settings,
122
            "UI_SYNNEFO_JS_URL", UI_MEDIA_URL + "js/")
123
UI_SYNNEFO_JS_LIB_URL = \
124
    getattr(settings,
125
            "UI_SYNNEFO_JS_LIB_URL", UI_SYNNEFO_JS_URL + "lib/")
126
UI_SYNNEFO_JS_WEB_URL = \
127
    getattr(settings, "UI_SYNNEFO_JS_WEB_URL", UI_SYNNEFO_JS_URL + "ui/web/")
128

    
129
# extensions
130
ENABLE_GLANCE = getattr(settings, 'UI_ENABLE_GLANCE', True)
131
GLANCE_API_URL = getattr(settings, 'UI_GLANCE_API_URL', '/glance')
132
DIAGNOSTICS_UPDATE_INTERVAL = \
133
    getattr(settings, 'UI_DIAGNOSTICS_UPDATE_INTERVAL', 2000)
134

    
135
# network settings
136
DEFAULT_NETWORK_TYPES = {'MAC_FILTERED': 'mac-filtering',
137
                         'PHYSICAL_VLAN': 'physical-vlan'}
138
NETWORK_TYPES = \
139
    getattr(settings,
140
            'UI_NETWORK_AVAILABLE_NETWORK_TYPES', DEFAULT_NETWORK_TYPES)
141
DEFAULT_NETWORK_SUBNETS = ['10.0.0.0/24', '192.168.1.1/24']
142
NETWORK_SUBNETS = \
143
    getattr(settings,
144
            'UI_NETWORK_AVAILABLE_SUBNETS', DEFAULT_NETWORK_SUBNETS)
145
NETWORK_DUPLICATE_NICS = \
146
    getattr(settings,
147
            'UI_NETWORK_ALLOW_DUPLICATE_VM_NICS', False)
148
NETWORK_STRICT_DESTROY = \
149
    getattr(settings,
150
            'UI_NETWORK_STRICT_DESTROY', False)
151
NETWORK_ALLOW_MULTIPLE_DESTROY = \
152
    getattr(settings,
153
            'UI_NETWORK_ALLOW_MULTIPLE_DESTROY', False)
154
AUTOMATIC_NETWORK_RANGE_FORMAT = getattr(settings,
155
                                         'UI_AUTOMATIC_NETWORK_RANGE_FORMAT',
156
                                         "192.168.%d.0/24").replace("%d", "{0}")
157
GROUP_PUBLIC_NETWORKS = getattr(settings, 'UI_GROUP_PUBLIC_NETWORKS', True)
158
GROUPED_PUBLIC_NETWORK_NAME = \
159
    getattr(settings, 'UI_GROUPED_PUBLIC_NETWORK_NAME', 'Internet')
160

    
161
USER_CATALOG_URL = getattr(settings, 'UI_USER_CATALOG_URL', '/user_catalogs')
162
FEEDBACK_POST_URL = getattr(settings, 'UI_FEEDBACK_POST_URL', '/feedback')
163
TRANSLATE_UUIDS = not getattr(settings, 'TRANSLATE_UUIDS', False)
164

    
165

    
166
def template(name, request, context):
167
    template_path = os.path.join(os.path.dirname(__file__), "templates/")
168
    current_template = template_path + name + '.html'
169
    t = loader.get_template(current_template)
170
    media_context = {
171
        'UI_MEDIA_URL': UI_MEDIA_URL,
172
        'SYNNEFO_JS_URL': UI_SYNNEFO_JS_URL,
173
        'SYNNEFO_JS_LIB_URL': UI_SYNNEFO_JS_LIB_URL,
174
        'SYNNEFO_JS_WEB_URL': UI_SYNNEFO_JS_WEB_URL,
175
        'SYNNEFO_IMAGES_URL': UI_SYNNEFO_IMAGES_URL,
176
        'SYNNEFO_CSS_URL': UI_SYNNEFO_CSS_URL,
177
        'SYNNEFO_JS_LIB_VERSION': SYNNEFO_JS_LIB_VERSION,
178
        'DEBUG': settings.DEBUG
179
    }
180
    context.update(media_context)
181
    return HttpResponse(t.render(RequestContext(request, context)))
182

    
183

    
184
def home(request):
185
    context = {'timeout': TIMEOUT,
186
               'project': '+nefo',
187
               'request': request,
188
               'current_lang': get_language() or 'en',
189
               'compute_api_url': json.dumps(COMPUTE_API_URL),
190
               'user_catalog_url': json.dumps(USER_CATALOG_URL),
191
               'feedback_post_url': json.dumps(FEEDBACK_POST_URL),
192
               'translate_uuids': json.dumps(TRANSLATE_UUIDS),
193
               # update interval settings
194
               'update_interval': UPDATE_INTERVAL,
195
               'update_interval_increase': UPDATE_INTERVAL_INCREASE,
196
               'update_interval_increase_after_calls':
197
               UPDATE_INTERVAL_INCREASE_AFTER_CALLS_COUNT,
198
               'update_interval_fast': UPDATE_INTERVAL_FAST,
199
               'update_interval_max': UPDATE_INTERVAL_MAX,
200
               'changes_since_alignment': CHANGES_SINCE_ALIGNMENT,
201
               'quotas_update_interval': QUOTAS_UPDATE_INTERVAL,
202
               'image_icons': IMAGE_ICONS,
203
               'logout_redirect': LOGOUT_URL,
204
               'login_redirect': LOGIN_URL,
205
               'auth_cookie_name': AUTH_COOKIE_NAME,
206
               'suggested_flavors': json.dumps(SUGGESTED_FLAVORS),
207
               'suggested_roles': json.dumps(SUGGESTED_ROLES),
208
               'vm_image_common_metadata': json.dumps(VM_IMAGE_COMMON_METADATA),
209
               'synnefo_version': SYNNEFO_JS_LIB_VERSION,
210
               'delay_on_blur': json.dumps(DELAY_ON_BLUR),
211
               'update_hidden_views': json.dumps(UPDATE_HIDDEN_VIEWS),
212
               'handle_window_exceptions': json.dumps(HANDLE_WINDOW_EXCEPTIONS),
213
               'skip_timeouts': json.dumps(SKIP_TIMEOUTS),
214
               'vm_name_template': json.dumps(VM_NAME_TEMPLATE),
215
               'flavors_disk_templates_info':
216
               json.dumps(FLAVORS_DISK_TEMPLATES_INFO),
217
               'support_ssh_os_list': json.dumps(SUPPORT_SSH_OS_LIST),
218
               'os_created_users': json.dumps(OS_CREATED_USERS),
219
               'userdata_keys_limit': json.dumps(MAX_SSH_KEYS_PER_USER),
220
               'use_glance': json.dumps(ENABLE_GLANCE),
221
               'glance_api_url': json.dumps(GLANCE_API_URL),
222
               'system_images_owners': json.dumps(SYSTEM_IMAGES_OWNERS),
223
               'custom_image_help_url': CUSTOM_IMAGE_HELP_URL,
224
               'image_deleted_title': json.dumps(IMAGE_DELETED_TITLE),
225
               'image_deleted_size_title': json.dumps(IMAGE_DELETED_SIZE_TITLE),
226
               'network_suggested_subnets': json.dumps(NETWORK_SUBNETS),
227
               'network_available_types': json.dumps(NETWORK_TYPES),
228
               'network_allow_duplicate_vm_nics':
229
               json.dumps(NETWORK_DUPLICATE_NICS),
230
               'network_strict_destroy': json.dumps(NETWORK_STRICT_DESTROY),
231
               'network_allow_multiple_destroy':
232
               json.dumps(NETWORK_ALLOW_MULTIPLE_DESTROY),
233
               'automatic_network_range_format':
234
               json.dumps(AUTOMATIC_NETWORK_RANGE_FORMAT),
235
               'grouped_public_network_name':
236
               json.dumps(GROUPED_PUBLIC_NETWORK_NAME),
237
               'group_public_networks': json.dumps(GROUP_PUBLIC_NETWORKS),
238
               'diagnostics_update_interval':
239
               json.dumps(DIAGNOSTICS_UPDATE_INTERVAL),
240
               'vm_hostname_format': json.dumps(VM_HOSTNAME_FORMAT)
241
               }
242
    return template('home', request, context)
243

    
244

    
245
def machines_console(request):
246
    host, port, password = ('', '', '')
247
    host = request.GET.get('host', '')
248
    port = request.GET.get('port', '')
249
    password = request.GET.get('password', '')
250
    machine = request.GET.get('machine', '')
251
    host_ip = request.GET.get('host_ip', '')
252
    host_ip_v6 = request.GET.get('host_ip_v6', '')
253
    context = {'host': host, 'port': port, 'password': password,
254
               'machine': machine, 'host_ip': host_ip, 'host_ip_v6': host_ip_v6}
255
    return template('machines_console', request, context)
256

    
257

    
258
def user_quota(request):
259
    get_user(request, settings.ASTAKOS_URL, usage=True)
260

    
261
    response = json.dumps(request.user['usage'])
262

    
263
    return HttpResponse(response, mimetype="application/json")
264

    
265

    
266
def js_tests(request):
267
    return template('tests', request, {})
268

    
269

    
270
CONNECT_LINUX_LINUX_MESSAGE = \
271
    _("""A direct connection to this machine can be established using the
272
<a target="_blank" href="http://en.wikipedia.org/wiki/Secure_Shell">
273
SSH Protocol</a>.
274
To do so open a terminal and type the following at the prompt to connect
275
to your machine:""")
276
CONNECT_LINUX_WINDOWS_MESSAGE = \
277
    _("""A direct connection to this machine can be established using
278
<a target="_blank"
279
href="http://en.wikipedia.org/wiki/Remote_Desktop_Services">
280
Remote Desktop Service</a>.
281
To do so, open the following file with an appropriate remote desktop client.""")
282
CONNECT_LINUX_WINDOWS_SUBMESSAGE = \
283
    _("""If you don't have a Remote Desktop client already installed,
284
we suggest the use of <a target="_blank"
285
href=
286
"http://sourceforge.net/projects/tsclient/files/latest/download?source=files">
287
tsclient</a>.<br /><span class="important">IMPORTANT: It may take up to 15
288
minutes for your Windows VM to become available
289
after its creation.</span>""")
290
CONNECT_WINDOWS_LINUX_MESSAGE = \
291
    _("""A direct connection to this machine can be established using the
292
<a target="_blank"
293
href="http://en.wikipedia.org/wiki/Secure_Shell">SSH Protocol</a>.
294
Open an ssh client such as PuTTY and type the following:""")
295
CONNECT_WINDOWS_LINUX_SUBMESSAGE = \
296
    _("""If you do not have an ssh client already installed,
297
<a target="_blank"
298
href="http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe">
299
Download PuTTY</a>""")
300

    
301
CONNECT_WINDOWS_WINDOWS_MESSAGE = \
302
    _("""A direct connection to this machine can be
303
established using Remote Desktop. Click on the following link, and if asked
304
open it using "Remote Desktop Connection".
305
<br /><span class="important">
306
IMPORTANT: It may take up to 15 minutes for your Windows VM to become available
307
after its creation.</span>""")
308
CONNECT_WINDOWS_WINDOWS_SUBMESSAGE = \
309
    _("""Save this file to disk for future use.""")
310

    
311
# info/subinfo for all os combinations
312
#
313
# [0] info gets displayed on top of the message box
314
# [1] subinfo gets displayed on the bottom as extra info
315
# provided to the user when needed
316
CONNECT_PROMPT_MESSAGES = {
317
    'linux': {
318
        'linux': [CONNECT_LINUX_LINUX_MESSAGE, ""],
319
        'windows': [CONNECT_LINUX_WINDOWS_MESSAGE,
320
                    CONNECT_LINUX_WINDOWS_SUBMESSAGE],
321
        'ssh_message': "ssh %(user)s@%(hostname)s"
322
    },
323
    'windows': {
324
        'linux': [CONNECT_WINDOWS_LINUX_MESSAGE,
325
                  CONNECT_WINDOWS_LINUX_SUBMESSAGE],
326
        'windows': [CONNECT_WINDOWS_WINDOWS_MESSAGE,
327
                    CONNECT_WINDOWS_WINDOWS_SUBMESSAGE],
328
        'ssh_message': "%(user)s@%(hostname)s"
329
    },
330
}
331

    
332
APPEND_CONNECT_PROMPT_MESSAGES = \
333
    getattr(settings, 'UI_CONNECT_PROMPT_MESSAGES', {})
334
for k, v in APPEND_CONNECT_PROMPT_MESSAGES.iteritems():
335
    CONNECT_PROMPT_MESSAGES[k].update(v)
336

    
337
# retrieve domain prefix from settings
338
DOMAIN_PREFIX = getattr(settings, 'MACHINE_DOMAIN_PREFIX', getattr(settings,
339
                        'BACKEND_PREFIX_ID', ""))
340

    
341
# domain template string
342
DOMAIN_TPL = "%s%%s" % DOMAIN_PREFIX
343

    
344

    
345
def machines_connect(request):
346
    ip_address = request.GET.get('ip_address', '')
347
    hostname = request.GET.get('hostname', '')
348
    operating_system = metadata_os = request.GET.get('os', '')
349
    server_id = request.GET.get('srv', 0)
350
    host_os = request.GET.get('host_os', 'Linux').lower()
351
    username = request.GET.get('username', None)
352
    domain = request.GET.get("domain", DOMAIN_TPL % int(server_id))
353

    
354
    # guess host os
355
    if host_os != "windows":
356
        host_os = 'linux'
357

    
358
    # guess username
359
    if not username:
360
        username = "root"
361

    
362
        if metadata_os.lower() in ['ubuntu', 'kubuntu', 'fedora']:
363
            username = "user"
364

    
365
        if metadata_os.lower() == "windows":
366
            username = "Administrator"
367

    
368
    # operating system provides ssh access
369
    ssh = False
370
    if operating_system != "windows":
371
        operating_system = "linux"
372
        ssh = True
373

    
374
    # rdp param is set, the user requested rdp file
375
    # check if we are on windows
376
    if operating_system == 'windows' and request.GET.get("rdp", False):
377

    
378
        # UI sent domain info (from vm metadata) use this
379
        # otherwise use our default snf-<vm_id> domain
380
        EXTRA_RDP_CONTENT = getattr(settings, 'UI_EXTRA_RDP_CONTENT', '')
381
        if callable(EXTRA_RDP_CONTENT):
382
            extra_rdp_content = EXTRA_RDP_CONTENT(server_id, ip_address,
383
                                                  hostname, username)
384
        else:
385
            extra_rdp_content = EXTRA_RDP_CONTENT % \
386
                {
387
                    'server_id': server_id,
388
                    'ip_address': ip_address,
389
                    'hostname': hostname,
390
                    'user': username
391
                }
392

    
393
        rdp_context = {
394
            'username': username,
395
            'domain': domain,
396
            'ip_address': ip_address,
397
            'hostname': hostname,
398
            'extra_content': extra_rdp_content
399
        }
400

    
401
        rdp_file_data = render_to_string("synnefo-windows.rdp", rdp_context)
402
        response = HttpResponse(rdp_file_data, mimetype='application/x-rdp')
403

    
404
        # proper filename, use server id and ip address
405
        filename = "%d-%s.rdp" % (int(server_id), hostname)
406
        response['Content-Disposition'] = 'attachment; filename=%s' % filename
407
    else:
408
        ssh_message = CONNECT_PROMPT_MESSAGES['linux'].get('ssh_message')
409
        if host_os == 'windows':
410
            ssh_message = CONNECT_PROMPT_MESSAGES['windows'].get('ssh_message')
411
        if callable(ssh_message):
412
            link_title = ssh_message(server_id, ip_address, hostname, username)
413
        else:
414
            link_title = ssh_message % {
415
                'server_id': server_id,
416
                'ip_address': ip_address,
417
                'hostname': hostname,
418
                'user': username
419
            }
420
        if (operating_system != "windows"):
421
            link_url = None
422

    
423
        else:
424
            link_title = _("Remote desktop to %s") % ip_address
425
            link_url = \
426
                "%s?ip_address=%s&os=%s&rdp=1&srv=%d&username=%s&domain=%s" \
427
                "&hostname=%s" % (
428
                    reverse("ui_machines_connect"), ip_address,
429
                    operating_system, int(server_id), username,
430
                    domain, hostname)
431

    
432
        # try to find a specific message
433
        try:
434
            connect_message = \
435
                CONNECT_PROMPT_MESSAGES[host_os][operating_system][0]
436
            subinfo = CONNECT_PROMPT_MESSAGES[host_os][operating_system][1]
437
        except KeyError:
438
            connect_message = \
439
                _("You are trying to connect from a %s "
440
                  "machine to a %s machine") % (host_os, operating_system)
441
            subinfo = ""
442

    
443
        response_object = {
444
            'ip': ip_address,
445
            'os': operating_system,
446
            'ssh': ssh,
447
            'info': unicode(connect_message),
448
            'subinfo': unicode(subinfo),
449
            'link': {'title': unicode(link_title), 'url': link_url}
450
        }
451
        response = \
452
            HttpResponse(json.dumps(response_object),
453
                         mimetype='application/json')  # no windows, no rdp
454

    
455
    return response