Revision 74831b0d

b/snf-cyclades-app/synnefo/ui/static/snf/js/models.js
1589 1589
                ip_address: this.get_hostname(),
1590 1590
                hostname: this.get_hostname(),
1591 1591
                os: this.get_os(),
1592
                host_os: host_os,
1592
                host_os: 'windows',
1593
                ports: JSON.stringify(this.get('SNF:port_forwarding') || {}),
1593 1594
                srv: this.id
1594 1595
            }
1595 1596
            
b/snf-cyclades-app/synnefo/ui/templates/synnefo-windows.rdp
34 34
gatewayprofileusagemethod:i:0
35 35
promptcredentialonce:i:1
36 36
username:s:{{ username }}
37
domain:s:{{ domain }}
38
full address:s:{% if hostname %}{{ hostname }}{% else %}{{ ip_address }}{% endif %}{% if extra_content %}
37
domain:s:{{ domain }}
{% if port %}
38
port:i:{{ port }}
39
{% endif %}full address:s:{% if hostname %}{{ hostname }}{% else %}{{ ip_address }}{% endif %}{% if extra_content %}
39 40
{{ extra_content }}{% endif %}
b/snf-cyclades-app/synnefo/ui/views.py
317 317
        'linux': [CONNECT_LINUX_LINUX_MESSAGE, ""],
318 318
        'windows': [CONNECT_LINUX_WINDOWS_MESSAGE,
319 319
                    CONNECT_LINUX_WINDOWS_SUBMESSAGE],
320
        'ssh_message': "ssh %(user)s@%(hostname)s"
320
        'ssh_message': "ssh %(user)s@%(hostname)s",
321
        'ssh_message_port': "ssh -p %(port)s %(user)s@%(hostname)s"
322

  
321 323
    },
322 324
    'windows': {
323 325
        'linux': [CONNECT_WINDOWS_LINUX_MESSAGE,
324 326
                  CONNECT_WINDOWS_LINUX_SUBMESSAGE],
325 327
        'windows': [CONNECT_WINDOWS_WINDOWS_MESSAGE,
326 328
                    CONNECT_WINDOWS_WINDOWS_SUBMESSAGE],
327
        'ssh_message': "%(user)s@%(hostname)s"
329
        'ssh_message': "%(user)s@%(hostname)s",
330
        'ssh_message_port': "%(user)s@%(hostname)s (port: %(port)s)"
328 331
    },
329 332
}
330 333

  
......
349 352
    host_os = request.GET.get('host_os', 'Linux').lower()
350 353
    username = request.GET.get('username', None)
351 354
    domain = request.GET.get("domain", DOMAIN_TPL % int(server_id))
355
    ports = json.loads(request.GET.get('ports', '{}'))
352 356

  
353 357
    # guess host os
354 358
    if host_os != "windows":
......
364 368
        if metadata_os.lower() == "windows":
365 369
            username = "Administrator"
366 370

  
371
    ssh_forward = ports.get("22", None)
372
    rdp_forward = ports.get("3389", None)
373

  
367 374
    # operating system provides ssh access
368 375
    ssh = False
369 376
    if operating_system != "windows":
......
373 380
    # rdp param is set, the user requested rdp file
374 381
    # check if we are on windows
375 382
    if operating_system == 'windows' and request.GET.get("rdp", False):
383
        port = '3389'
384
        if rdp_forward:
385
            hostname = rdp_forward.get('host', hostname)
386
            ip_address = rdp_forward.get('host', ip_address)
387
            port = str(rdp_forward.get('port', '3389'))
388

  
376 389
        extra_rdp_content = ''
377 390
        # UI sent domain info (from vm metadata) use this
378 391
        # otherwise use our default snf-<vm_id> domain
......
387 400
                        'server_id': server_id,
388 401
                        'ip_address': ip_address,
389 402
                        'hostname': hostname,
390
                        'user': username
403
                        'user': username,
404
                        'port': port
391 405
                    }
392 406

  
393 407
        rdp_context = {
......
395 409
            'domain': domain,
396 410
            'ip_address': ip_address,
397 411
            'hostname': hostname,
412
            'port': request.GET.get('port', port),
398 413
            'extra_content': extra_rdp_content
399 414
        }
400 415

  
......
405 420
        filename = "%d-%s.rdp" % (int(server_id), hostname)
406 421
        response['Content-Disposition'] = 'attachment; filename=%s' % filename
407 422
    else:
408
        ssh_message = CONNECT_PROMPT_MESSAGES['linux'].get('ssh_message')
423
        message_key = "ssh_message"
424
        ip_address = ip_address
425
        hostname = hostname
426
        port = ''
427
        if ssh_forward:
428
            message_key = 'ssh_message_port'
429
            hostname = ssh_forward.get('host', hostname)
430
            ip_address = ssh_forward.get('host', ip_address)
431
            port = str(ssh_forward.get('port', '22'))
432

  
433
        ssh_message = CONNECT_PROMPT_MESSAGES['linux'].get(message_key)
409 434
        if host_os == 'windows':
410
            ssh_message = CONNECT_PROMPT_MESSAGES['windows'].get('ssh_message')
435
            ssh_message = CONNECT_PROMPT_MESSAGES['windows'].get(message_key)
411 436
        if callable(ssh_message):
412 437
            link_title = ssh_message(server_id, ip_address, hostname, username)
413 438
        else:
......
415 440
                'server_id': server_id,
416 441
                'ip_address': ip_address,
417 442
                'hostname': hostname,
418
                'user': username
443
                'user': username,
444
                'port': port
419 445
            }
420 446
        if (operating_system != "windows"):
421 447
            link_url = None
422 448

  
423 449
        else:
424 450
            link_title = _("Remote desktop to %s") % ip_address
451
            if rdp_forward:
452
                hostname = rdp_forward.get('host', hostname)
453
                ip_address = rdp_forward.get('host', ip_address)
454
                port = str(rdp_forward.get('port', '3389'))
455
                link_title = _("Remote desktop to %s (port %s)") % (ip_address,
456
                                                                    port)
425 457
            link_url = \
426 458
                "%s?ip_address=%s&os=%s&rdp=1&srv=%d&username=%s&domain=%s" \
427
                "&hostname=%s" % (
459
                "&hostname=%s&port=%s" % (
428 460
                    reverse("ui_machines_connect"), ip_address,
429 461
                    operating_system, int(server_id), username,
430
                    domain, hostname)
462
                    domain, hostname, port)
431 463

  
432 464
        # try to find a specific message
433 465
        try:

Also available in: Unified diff