Revision 6f4c1371 ui/views.py

b/ui/views.py
86 86
    context = {'host': host, 'port': port, 'password': password, 'machine': machine, 'host_ip': host_ip}
87 87
    return template('machines_console', context)
88 88

  
89

  
90
CONNECT_LINUX_LINUX_MESSAGE = _("Trying to connect from linux to linux")
91
CONNECT_LINUX_WINDOWS_MESSAGE = _("Trying to connect from linux to windows")
92
CONNECT_WINDOWS_LINUX_MESSAGE = _("Trying to connect from windows to linux")
93
CONNECT_WINDOWS_WINDOWS_MESSAGE = _("Trying to connect from windows to windows")
94

  
95
CONNECT_PROMT_MESSAGES = {
96
    'linux': {
97
            'linux': CONNECT_LINUX_LINUX_MESSAGE,
98
            'windows': CONNECT_LINUX_WINDOWS_MESSAGE
99
        },
100
    'windows': {
101
            'linux': CONNECT_WINDOWS_LINUX_MESSAGE,
102
            'windows': CONNECT_WINDOWS_WINDOWS_MESSAGE
103
        }
104
    }
105

  
89 106
def machines_connect(request):
90 107
    ip_address = request.GET.get('ip_address','')
91 108
    operating_system = request.GET.get('os','')
109
    host_os = request.GET.get('host_os','Linux').lower()
110

  
111
    if operating_system != "windows":
112
        operating_system = "linux"
113

  
92 114
    if operating_system == 'windows' and request.GET.get("rdp", False): #check if we are on windows
93 115
        rdp_file = os.path.join(os.path.dirname(__file__), "static/") + 'synnefo-windows.rdp'
94 116
        connect_data = open(rdp_file, 'r').read()
......
109 131
            link_url = "ssh://%s/" % ip_address
110 132
            link_title = link_url
111 133

  
134
        # try to find a specific message
135
        try:
136
            connect_message = CONNECT_PROMT_MESSAGES[host_os][operating_system]
137
        except KeyError:
138
            connect_message = _("You are trying to connect from a %s machine to a %s machine") % (host_os, operating_system)
139

  
112 140
        response_object = {
113 141
                'ip': ip_address,
114 142
                'os': operating_system,
115 143
                'ssh': ssh,
116
                'info': unicode(info),
144
                'info': unicode(connect_message),
117 145
                'link': {'title': unicode(link_title), 'url': link_url}
118 146
            }
119 147
        response = HttpResponse(json.dumps(response_object), mimetype='application/json')  #no windows, no rdp
148

  
120 149
    return response
121 150

  
122 151

  

Also available in: Unified diff