Revision d0e3f226

/dev/null
1
screen mode id:i:2
2
desktopwidth:i:1920
3
desktopheight:i:1080
4
session bpp:i:32
5
winposstr:s:0,1,210,229,1234,996
6
compression:i:1
7
keyboardhook:i:2
8
audiomode:i:0
9
redirectprinters:i:1
10
redirectcomports:i:0
11
redirectsmartcards:i:0
12
redirectclipboard:i:0
13
redirectposdevices:i:0
14
drivestoredirect:s:
15
displayconnectionbar:i:1
16
autoreconnection enabled:i:0
17
authentication level:i:2
18
prompt for credentials:i:0
19
negotiate security layer:i:1
20
remoteapplicationmode:i:0
21
alternate shell:s:
22
shell working directory:s:
23
disable wallpaper:i:0
24
disable full window drag:i:0
25
allow desktop composition:i:1
26
allow font smoothing:i:1
27
disable menu anims:i:0
28
disable themes:i:0
29
disable cursor setting:i:0
30
bitmapcachepersistenable:i:1
31
gatewayhostname:s:
32
gatewayusagemethod:i:0
33
gatewaycredentialssource:i:4
34
gatewayprofileusagemethod:i:0
35
promptcredentialonce:i:1
b/ui/static/synnefo.js
1236 1236
        //ajax_success('DEFAULT');
1237 1237
        return false;
1238 1238
    }
1239

  
1239
    
1240
    // prefer metadata values for specific options (username, domain)
1240 1241
    var username_meta_key = 'User';
1242
    var domain_meta_key = "Domain";
1241 1243

  
1242 1244
    var serverID = serverIDs.pop();
1243 1245
    var machine = get_machine(serverID);
......
1245 1247
    
1246 1248
    try {
1247 1249
        var serverIP = machine.addresses.values[0].values[0].addr;
1248
    } catch(err) { var serverIP = 'undefined'; }
1250
    } catch (err) { var serverIP = 'undefined'; }
1249 1251

  
1250 1252
    try {
1251 1253
        var os = os_icon(machine.metadata);
1252
    } catch(err) { var os = 'undefined'; }
1254
    } catch (err) { var os = 'undefined'; }
1253 1255

  
1254 1256
    var username = "";
1255 1257
    try {
1256 1258
        username = machine.metadata.values[username_meta_key];
1257
    } catch(err){ username = undefined}
1259
    } catch (err) { username = undefined }
1260

  
1261
    var domain = "";
1262
    try {
1263
        domain = machine.metadata.values[domain_meta_key];
1264
    } catch (erro) { domain = undefined }
1258 1265

  
1259 1266
    var params_url = '?ip_address=' + serverIP + '&os=' + os + "&host_os=" + $.client.os + "&srv=" + serverID;
1260 1267

  
1261 1268
    if (username) {
1262 1269
        params_url += "&username=" + username;
1263 1270
    }
1271

  
1272
    if (domain) {
1273
        params_url += "&domain=" + domain;
1274
    }
1264 1275
    
1265 1276
    if ($.client.os == "Windows" && os == "windows") {
1277
        // request rdp file
1266 1278
        window.open('machines/connect' + params_url + "&rdp=1");
1267 1279
        return;
1268 1280
    }
1269 1281
    
1282
    // FIXME: I18n ???
1270 1283
    var title = 'Connect to: ' + '<span class="machine-title"><img src="static/icons/machines/small/'+os+'-on.png" /> '+serverName+'</span>';
1271

  
1284
    
1285
    // open msg box and fill it with json data retrieved from connect machine view
1272 1286
    try {
1273
        msg_box({title:title, content:'loading...',extra:'',
1274
        'ajax':'machines/connect' + params_url,
1275
        parse_data:function(data){
1276
            var box_content = "<a href='"+data.link.url+"'>"+data.link.title+"</a>";
1277
            if (!data.link.url) {
1278
                box_content = "<span class='cmd'>"+data.link.title+"</span>";
1287
        // open msg box
1288
        msg_box({
1289
            title:title, 
1290
            content:'loading...',
1291
            extra:'', 'ajax':'machines/connect' + params_url,
1292
            parse_data:function(data){
1293
                var box_content = "<a href='"+data.link.url+"'>"+data.link.title+"</a>";
1294
                if (!data.link.url) {
1295
                    box_content = "<span class='cmd'>"+data.link.title+"</span>";
1296
                }
1297
                data.title = false;
1298
                data.content = data.info;
1299
                data.extra = box_content;
1300
                return data;
1279 1301
            }
1280
            data.title = false;
1281
            data.content = data.info;
1282
            data.extra = box_content;
1283
            return data;
1284
        }
1285 1302
        });
1286 1303
    } catch (error) {
1304
        // if msg box fails fallback redirecting the user to the connect url
1287 1305
        window.open('machines/connect' + params_url);
1288 1306
    }
1289 1307

  
b/ui/templates/synnefo-windows.rdp
1
screen mode id:i:2
2
desktopwidth:i:1920
3
desktopheight:i:1080
4
session bpp:i:32
5
winposstr:s:0,1,210,229,1234,996
6
compression:i:1
7
keyboardhook:i:2
8
audiomode:i:0
9
redirectprinters:i:1
10
redirectcomports:i:0
11
redirectsmartcards:i:0
12
redirectclipboard:i:0
13
redirectposdevices:i:0
14
drivestoredirect:s:
15
displayconnectionbar:i:1
16
autoreconnection enabled:i:0
17
authentication level:i:2
18
prompt for credentials:i:0
19
negotiate security layer:i:1
20
remoteapplicationmode:i:0
21
alternate shell:s:
22
shell working directory:s:
23
disable wallpaper:i:0
24
disable full window drag:i:0
25
allow desktop composition:i:1
26
allow font smoothing:i:1
27
disable menu anims:i:0
28
disable themes:i:0
29
disable cursor setting:i:0
30
bitmapcachepersistenable:i:1
31
gatewayhostname:s:
32
gatewayusagemethod:i:0
33
gatewaycredentialssource:i:4
34
gatewayprofileusagemethod:i:0
35
promptcredentialonce:i:1
36
username:s:{{ username }}
37
domain:s:{{ domain }}
38
full address:s:{{ ip_address }}
b/ui/views.py
135 135
    server_id = request.GET.get('srv', 0)
136 136
    host_os = request.GET.get('host_os','Linux').lower()
137 137
    username = request.GET.get('username', None)
138
    domain = request.GET.get("domain", "snf-%d" % int(server_id))
138 139

  
140
    # guess host os
139 141
    if host_os != "windows":
140 142
        host_os = 'linux'
141 143

  
144
    # guess username
145
    if not username:
146
        username = "root"
147

  
148
        if metadata_os.lower() in ['ubuntu', 'kubuntu', 'fedora']:
149
            username = "user"
150

  
151
        if metadata_os.lower() == "windows":
152
            username = "Administrator"
153

  
154
    # operating system provides ssh access
155
    ssh = False
142 156
    if operating_system != "windows":
143 157
        operating_system = "linux"
158
        ssh = True
144 159

  
145 160
    # rdp param is set, the user requested rdp file
146
    if operating_system == 'windows' and request.GET.get("rdp", False): #check if we are on windows
147
        rdp_file = os.path.join(os.path.dirname(__file__), "static/") + 'synnefo-windows.rdp'
148
        connect_data = open(rdp_file, 'r').read()
149
        connect_data = connect_data + 'full address:s:' + ip_address + '\n'
150
        response = HttpResponse(connect_data, mimetype='application/x-rdp')
161
    # check if we are on windows
162
    if operating_system == 'windows' and request.GET.get("rdp", False):
163

  
164
        # UI sent domain info (from vm metadata) use this
165
        # otherwise use our default snf-<vm_id> domain
166
        rdp_context = {
167
                'username': username,
168
                'domain': domain,
169
                'ip_address': ip_address
170
        }
171

  
172
        rdp_file_data = render_to_string("synnefo-windows.rdp", rdp_context)
173
        response = HttpResponse(rdp_file_data, mimetype='application/x-rdp')
151 174

  
152 175
        # proper filename, use server id and ip address
153 176
        filename = "%d-%s.rdp" % (int(server_id), ip_address)
154 177
        response['Content-Disposition'] = 'attachment; filename=%s' % filename
155 178
    else:
156
        # no rdp requested return json object with info on how to connect
157
        ssh = False
158
        if (operating_system != "windows"):
159
            ssh = True
160

  
161 179
        link_title = _("Remote desktop to %s") % ip_address
162
        link_url = "%s?ip_address=%s&os=%s&rdp=1&srv=%d" % (reverse("machines-connect"), ip_address, operating_system,
163
                int(server_id))
164

  
165
        user = username
166
        if not user:
167
            user = "root"
168
            if metadata_os.lower() in ['ubuntu', 'kubuntu', 'fedora']:
169
                user = "user"
180
        link_url = "%s?ip_address=%s&os=%s&rdp=1&srv=%d&username=%s&domain=%s" % (
181
                reverse("machines-connect"), ip_address, operating_system,int(server_id), username, domain)
170 182

  
171 183
        if (operating_system != "windows"):
172
            link_title = "ssh %s@%s" % (user, ip_address)
184
            link_title = "ssh %s@%s" % (username, ip_address)
173 185
            link_url = None
174 186

  
175 187
            if host_os == "windows":
176
                link_title = "%s@%s" % (user, ip_address)
188
                link_title = "%s@%s" % (username, ip_address)
177 189

  
178 190
        # try to find a specific message
179 191
        try:

Also available in: Unified diff