Revision b687587e ui/views.py
b/ui/views.py | ||
---|---|---|
39 | 39 |
from django.utils.translation import get_language |
40 | 40 |
from django.utils import simplejson as json |
41 | 41 |
from django.shortcuts import render_to_response |
42 |
from django.core.urlresolvers import reverse |
|
42 | 43 |
|
43 | 44 |
TIMEOUT = settings.TIMEOUT |
44 | 45 |
UPDATE_INTERVAL = settings.UPDATE_INTERVAL |
... | ... | |
88 | 89 |
def machines_connect(request): |
89 | 90 |
ip_address = request.GET.get('ip_address','') |
90 | 91 |
operating_system = request.GET.get('os','') |
91 |
if operating_system == 'windows': #check if we are on windows |
|
92 |
if operating_system == 'windows' and request.GET.get("rdp", False): #check if we are on windows
|
|
92 | 93 |
rdp_file = os.path.join(os.path.dirname(__file__), "static/") + 'synnefo-windows.rdp' |
93 | 94 |
connect_data = open(rdp_file, 'r').read() |
94 | 95 |
connect_data = connect_data + 'full address:s:' + ip_address + '\n' |
95 | 96 |
response = HttpResponse(connect_data, mimetype='application/x-rdp') |
96 | 97 |
response['Content-Disposition'] = 'attachment; filename=synnefo-windows.rdp' |
97 | 98 |
else: |
98 |
response = HttpResponse("Try ssh maybe") #no windows, no rdp |
|
99 |
ssh = False |
|
100 |
if (operating_system != "windows"): |
|
101 |
ssh = True |
|
102 |
|
|
103 |
info = _("Connect on windows using the following RDP shortcut file") |
|
104 |
link_title = _("Windows RDP shortcut file") |
|
105 |
link_url = "%s?ip_address=%s&os=%s&rdp=1" % (reverse("machines-connect"), ip_address, operating_system) |
|
106 |
|
|
107 |
if (operating_system != "windows"): |
|
108 |
info = _("Connect on linux machine using the following url") |
|
109 |
link_url = "ssh://%s/" % ip_address |
|
110 |
link_title = link_url |
|
111 |
|
|
112 |
response_object = { |
|
113 |
'ip': ip_address, |
|
114 |
'os': operating_system, |
|
115 |
'ssh': ssh, |
|
116 |
'info': unicode(info), |
|
117 |
'link': {'title': unicode(link_title), 'url': link_url} |
|
118 |
} |
|
119 |
response = HttpResponse(json.dumps(response_object), mimetype='application/json') #no windows, no rdp |
|
99 | 120 |
return response |
100 | 121 |
|
101 | 122 |
|
Also available in: Unified diff