Statistics
| Branch: | Tag: | Revision:

root / snf-cyclades-app / synnefo / ui / views.py @ 3f339d85

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
from synnefo_branding import settings as snf_settings
47

    
48
from synnefo.util.version import get_component_version
49

    
50
from snf_django.lib.astakos import get_user
51

    
52
SYNNEFO_JS_LIB_VERSION = get_component_version('app')
53

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

    
57
# UI preferences settings
58
TIMEOUT = getattr(settings, "TIMEOUT", 10000)
59
UPDATE_INTERVAL = getattr(settings, "UI_UPDATE_INTERVAL", 5000)
60
CHANGES_SINCE_ALIGNMENT = getattr(settings, "UI_CHANGES_SINCE_ALIGNMENT", 0)
61
UPDATE_INTERVAL_INCREASE = getattr(settings, "UI_UPDATE_INTERVAL_INCREASE", 500)
62
UPDATE_INTERVAL_INCREASE_AFTER_CALLS_COUNT = \
63
    getattr(settings, "UI_UPDATE_INTERVAL_INCREASE_AFTER_CALLS_COUNT", 3)
64
UPDATE_INTERVAL_FAST = getattr(settings, "UI_UPDATE_INTERVAL_FAST", 2500)
65
UPDATE_INTERVAL_MAX = getattr(settings, "UI_UPDATE_INTERVAL_MAX", 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
UNKNOWN_OS = getattr(settings, "UI_UNKNOWN_OS", "unknown")
86
LOGOUT_URL = getattr(settings, "UI_LOGOUT_URL", '/im/authenticate')
87
LOGIN_URL = getattr(settings, "UI_LOGIN_URL", '/im/login')
88
AUTH_COOKIE_NAME = getattr(settings, "UI_AUTH_COOKIE_NAME", 'synnefo_user')
89

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

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

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

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

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

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

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

    
162
USER_CATALOG_URL = getattr(settings, 'UI_USER_CATALOG_URL', '/astakos/api/user_catalogs')
163
FEEDBACK_POST_URL = getattr(settings, 'UI_FEEDBACK_POST_URL', '/astakos/api/feedback')
164
TRANSLATE_UUIDS = not getattr(settings, 'TRANSLATE_UUIDS', False)
165
ACCOUNTS_API_URL = getattr(settings, 'UI_ACCOUNTS_API_URL', '/astakos/api')
166

    
167

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

    
185

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

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

    
259

    
260
def js_tests(request):
261
    return template('tests', request, {})
262

    
263

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

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

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

    
326
APPEND_CONNECT_PROMPT_MESSAGES = \
327
    getattr(settings, 'UI_CONNECT_PROMPT_MESSAGES', {})
328
for k, v in APPEND_CONNECT_PROMPT_MESSAGES.iteritems():
329
    CONNECT_PROMPT_MESSAGES[k].update(v)
330

    
331
# retrieve domain prefix from settings
332
DOMAIN_PREFIX = getattr(settings, 'MACHINE_DOMAIN_PREFIX', getattr(settings,
333
                        'BACKEND_PREFIX_ID', ""))
334

    
335
# domain template string
336
DOMAIN_TPL = "%s%%s" % DOMAIN_PREFIX
337

    
338

    
339
def machines_connect(request):
340
    ip_address = request.GET.get('ip_address', '')
341
    hostname = request.GET.get('hostname', '')
342
    operating_system = metadata_os = request.GET.get('os', '')
343
    server_id = request.GET.get('srv', 0)
344
    host_os = request.GET.get('host_os', 'Linux').lower()
345
    username = request.GET.get('username', None)
346
    domain = request.GET.get("domain", DOMAIN_TPL % int(server_id))
347

    
348
    # guess host os
349
    if host_os != "windows":
350
        host_os = 'linux'
351

    
352
    # guess username
353
    if not username:
354
        username = "root"
355

    
356
        if metadata_os.lower() in ['ubuntu', 'kubuntu', 'fedora']:
357
            username = "user"
358

    
359
        if metadata_os.lower() == "windows":
360
            username = "Administrator"
361

    
362
    # operating system provides ssh access
363
    ssh = False
364
    if operating_system != "windows":
365
        operating_system = "linux"
366
        ssh = True
367

    
368
    # rdp param is set, the user requested rdp file
369
    # check if we are on windows
370
    if operating_system == 'windows' and request.GET.get("rdp", False):
371

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

    
387
        rdp_context = {
388
            'username': username,
389
            'domain': domain,
390
            'ip_address': ip_address,
391
            'hostname': hostname,
392
            'extra_content': extra_rdp_content
393
        }
394

    
395
        rdp_file_data = render_to_string("synnefo-windows.rdp", rdp_context)
396
        response = HttpResponse(rdp_file_data, mimetype='application/x-rdp')
397

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

    
417
        else:
418
            link_title = _("Remote desktop to %s") % ip_address
419
            link_url = \
420
                "%s?ip_address=%s&os=%s&rdp=1&srv=%d&username=%s&domain=%s" \
421
                "&hostname=%s" % (
422
                    reverse("ui_machines_connect"), ip_address,
423
                    operating_system, int(server_id), username,
424
                    domain, hostname)
425

    
426
        # try to find a specific message
427
        try:
428
            connect_message = \
429
                CONNECT_PROMPT_MESSAGES[host_os][operating_system][0]
430
            subinfo = CONNECT_PROMPT_MESSAGES[host_os][operating_system][1]
431
        except KeyError:
432
            connect_message = \
433
                _("You are trying to connect from a %s "
434
                  "machine to a %s machine") % (host_os, operating_system)
435
            subinfo = ""
436

    
437
        response_object = {
438
            'ip': ip_address,
439
            'os': operating_system,
440
            'ssh': ssh,
441
            'info': unicode(connect_message),
442
            'subinfo': unicode(subinfo),
443
            'link': {'title': unicode(link_title), 'url': link_url}
444
        }
445
        response = \
446
            HttpResponse(json.dumps(response_object),
447
                         mimetype='application/json')  # no windows, no rdp
448

    
449
    return response
450