[ganeti/ganeti_webmgr] ea2b102 Added ssh_proxy() and a URL to reference it. (3 commits)

1 view
Skip to first unread message

g...@osuosl.org

unread,
Dec 20, 2013, 1:50:24 PM12/20/13
to ganeti-web...@googlegroups.com
The branch, bug/15495 has been updated

Old revision: ad99845c074fca9e5d21a2cd1dbc21ebafe4be4a, new revision: ea2b1026d99d10b0f0043555606c3a995a40903b.
via ea2b1026d99d10b0f0043555606c3a995a40903b (commit)
via 03806b33fa5dc77a8dbbf8081b518298793004f0 (commit)
via 2772354f9f09359d0a13cd1822aef9b07e24a42c (commit)
from ad99845c074fca9e5d21a2cd1dbc21ebafe4be4a (commit)

- Log -----------------------------------------------------------------
commit ea2b1026d99d10b0f0043555606c3a995a40903b
Author: Jack Twilley <j...@osuosl.org>
Date: Fri Dec 20 10:43:41 2013 -0800

Added ssh_proxy() and a URL to reference it.

This will give jsTerm something to hang its socket on.

refs #15495

commit 03806b33fa5dc77a8dbbf8081b518298793004f0
Author: Jack Twilley <j...@osuosl.org>
Date: Fri Dec 20 10:42:57 2013 -0800

Renamed VNC proxy to console proxy.

Mostly cosmetic but still necessary.

refs #15495

commit 2772354f9f09359d0a13cd1822aef9b07e24a42c
Author: Jack Twilley <j...@osuosl.org>
Date: Fri Dec 20 10:41:58 2013 -0800

First steps towards adding jsTerm support.

Copied the novnc.html to jsterm.html. This will require some tweaking
before jsTerm itself can be added.

refs #15495


Summary of changes:
ganeti_webmgr/ganeti_web/settings/base.py | 2 +-
ganeti_webmgr/ganeti_web/settings/settings.py.dist | 4 ++--
.../virtual_machine/{novnc.html => jsterm.html} | 0
ganeti_webmgr/virtualmachines/models.py | 10 +++++-----
ganeti_webmgr/virtualmachines/urls.py | 3 +++
ganeti_webmgr/virtualmachines/views.py | 18 ++++++++++++++++++
6 files changed, 29 insertions(+), 8 deletions(-)
copy ganeti_webmgr/templates/ganeti/virtual_machine/{novnc.html => jsterm.html} (100%)

diff --git a/ganeti_webmgr/ganeti_web/settings/base.py b/ganeti_webmgr/ganeti_web/settings/base.py
index 88514a1..43ed494 100644
--- a/ganeti_webmgr/ganeti_web/settings/base.py
+++ b/ganeti_webmgr/ganeti_web/settings/base.py
@@ -343,5 +343,5 @@ LOCALE_PATHS = (
# minutes.
LAZY_CACHE_REFRESH = 600000
# Other GWM Stuff
-VNC_PROXY = 'localhost:8888'
+CONSOLE_PROXY = 'localhost:8888'
RAPI_CONNECT_TIMEOUT = 3

diff --git a/ganeti_webmgr/ganeti_web/settings/settings.py.dist b/ganeti_webmgr/ganeti_web/settings/settings.py.dist
index 513633d..565e85a 100644
--- a/ganeti_webmgr/ganeti_web/settings/settings.py.dist
+++ b/ganeti_webmgr/ganeti_web/settings/settings.py.dist
@@ -135,8 +135,8 @@ ALLOW_OPEN_REGISTRATION = True
# minutes.
LAZY_CACHE_REFRESH = 600000

-# VNC Proxy. This will use a proxy to create local ports that are forwarded to
-# the virtual machines. It allows you to control access to the VNC servers.
+# Console Proxy. This will use a proxy to create local ports that are forwarded
+# to the virtual machines. It allows you to control access to the consoles.
#
# Expected values:
# String syntax: "HOST:CONTROL_PORT", for example: "localhost:8888". If

diff --git a/ganeti_webmgr/templates/ganeti/virtual_machine/novnc.html b/ganeti_webmgr/templates/ganeti/virtual_machine/jsterm.html
similarity index 100%
copy from ganeti_webmgr/templates/ganeti/virtual_machine/novnc.html
copy to ganeti_webmgr/templates/ganeti/virtual_machine/jsterm.html

diff --git a/ganeti_webmgr/virtualmachines/models.py b/ganeti_webmgr/virtualmachines/models.py
index 21058c7..540d0d1 100644
--- a/ganeti_webmgr/virtualmachines/models.py
+++ b/ganeti_webmgr/virtualmachines/models.py
@@ -11,7 +11,7 @@ from utils.client import REPLACE_DISK_AUTO
from utils.fields import LowerCaseCharField
from vm_templates.models import VirtualMachineTemplate

-if settings.VNC_PROXY:
+if settings.CONSOLE_PROXY:
from utils.vncdaemon.vapclient import request_forwarding, request_ssh


@@ -293,8 +293,8 @@ class VirtualMachine(CachedClusterObject):

command = self.rapi.GetInstanceConsole(self.hostname)["command"]

- if settings.VNC_PROXY:
- proxy_server = settings.VNC_PROXY.split(":")
+ if settings.CONSOLE_PROXY:
+ proxy_server = settings.CONSOLE_PROXY.split(":")
password = generate_random_password()
sport = request_ssh(proxy_server, sport, self.info["pnode"],
self.info["network_port"], password, command)
@@ -316,8 +316,8 @@ class VirtualMachine(CachedClusterObject):
node = info_['pnode']

# use proxy for VNC connection
- if settings.VNC_PROXY:
- proxy_server = settings.VNC_PROXY.split(":")
+ if settings.CONSOLE_PROXY:
+ proxy_server = settings.CONSOLE_PROXY.split(":")
password = generate_random_password()
result = request_forwarding(proxy_server, node, port, password,
sport=sport, tls=tls)

diff --git a/ganeti_webmgr/virtualmachines/urls.py b/ganeti_webmgr/virtualmachines/urls.py
index 053ab0f..eb1934a 100644
--- a/ganeti_webmgr/virtualmachines/urls.py
+++ b/ganeti_webmgr/virtualmachines/urls.py
@@ -35,6 +35,9 @@ urlpatterns = patterns(
url(r'^%s/vnc_proxy/?$' % vm_prefix, 'vnc_proxy',
name="instance-vnc-proxy"),

+ url(r'^%s/ssh_proxy/?$' % vm_prefix, 'ssh_proxy',
+ name="instance-ssh-proxy"),
+
url(r'^%s/shutdown/?$' % vm_prefix, 'shutdown', name="instance-shutdown"),

url(r'^%s/shutdown-now/?$' % vm_prefix, 'shutdown_now',

diff --git a/ganeti_webmgr/virtualmachines/views.py b/ganeti_webmgr/virtualmachines/views.py
index 37c144a..0adfb62 100644
--- a/ganeti_webmgr/virtualmachines/views.py
+++ b/ganeti_webmgr/virtualmachines/views.py
@@ -291,6 +291,24 @@ def vnc_proxy(request, cluster_slug, instance):

@require_POST
@login_required
+def ssh_proxy(request, cluster_slug, instance):
+ vm = get_object_or_404(VirtualMachine, hostname=instance,
+ cluster__slug=cluster_slug)
+ user = request.user
+ if not (user.is_superuser
+ or user.has_any_perms(vm, ['admin', 'power'])
+ or user.has_perm('admin', vm.cluster)):
+ return HttpResponseForbidden(_('You do not have permission '
+ 'to connect to this console'))
+
+ use_tls = bool(request.POST.get("tls"))
+ result = json.dumps(vm.setup_ssh_forwarding())
+
+ return HttpResponse(result, mimetype="application/json")
+
+
+@require_POST
+@login_required
def shutdown(request, cluster_slug, instance):
vm = get_object_or_404(VirtualMachine, hostname=instance,
cluster__slug=cluster_slug)
Reply all
Reply to author
Forward
0 new messages