[Kimchi-devel] [PATCH 1/2] Add websockify as Kimchi dependency

Aline Manera alinefm at linux.vnet.ibm.com
Thu Oct 2 20:13:07 UTC 2014


websockify is present in all supported Linux distributions (RHEL6.5,
RHEL7, Fedora20, Ubuntu 14.04 and openSUSE 13.1) so instead of importing
its code into Kimchi source source structure we must add its package as
a Kimchi dependency and use it as is.

Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
 contrib/DEBIAN/control.in     |  1 +
 contrib/kimchi.spec.fedora.in |  1 +
 contrib/kimchi.spec.suse.in   |  1 +
 docs/README.md                |  7 ++++---
 src/kimchi/server.py          |  2 +-
 src/kimchi/vnc.py             | 22 ++++++++++++++--------
 6 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/contrib/DEBIAN/control.in b/contrib/DEBIAN/control.in
index 99546fa..2c6a819 100644
--- a/contrib/DEBIAN/control.in
+++ b/contrib/DEBIAN/control.in
@@ -6,6 +6,7 @@ Architecture: all
 Depends: python-cherrypy3 (>= 3.2.0),
          python-cheetah,
          python-imaging,
+         websockify,
          python-jsonschema (>= 1.3.0),
          python-libvirt,
          gettext,
diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in
index 4327376..f2888b8 100644
--- a/contrib/kimchi.spec.fedora.in
+++ b/contrib/kimchi.spec.fedora.in
@@ -12,6 +12,7 @@ Requires:	libvirt
 Requires:	libvirt-python
 Requires:	python-cherrypy >= 3.2.0
 Requires:	python-cheetah
+Requires:	python-websockify
 Requires:	m2crypto
 Requires:	python-imaging
 Requires:	libxml2-python
diff --git a/contrib/kimchi.spec.suse.in b/contrib/kimchi.spec.suse.in
index 4386d2d..8af9147 100644
--- a/contrib/kimchi.spec.suse.in
+++ b/contrib/kimchi.spec.suse.in
@@ -12,6 +12,7 @@ Requires:	libvirt
 Requires:	libvirt-python
 Requires:	python-CherryPy >= 3.2.0
 Requires:	python-Cheetah
+Requires:	python-websockify
 Requires:	python-imaging
 Requires:	python-M2Crypto
 Requires:	python-libxml2
diff --git a/docs/README.md b/docs/README.md
index 19e8a68..02c264f 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -55,7 +55,7 @@ Install Dependencies
                         python-ipaddr python-lxml nfs-utils \
                         iscsi-initiator-utils libxslt pyparted nginx \
                         policycoreutils-python python-libguestfs \
-                        libguestfs-tools python-requests
+                        libguestfs-tools python-requests python-websockify
      # If using RHEL6, install the following additional packages:
      $ sudo yum install python-unittest2 python-ordereddict
      # Restart libvirt to allow configuration changes to take effect
@@ -79,7 +79,7 @@ for more information on how to configure your system to access this repository.
                            sosreport python-ipaddr python-lxml nfs-common \
                            open-iscsi lvm2 xsltproc python-parted nginx \
                            firewalld python-guestfs libguestfs-tools \
-                           python-requests
+                           python-requests websockify
 
     Packages version requirement:
         python-jsonschema >= 1.3.0
@@ -94,7 +94,8 @@ for more information on how to configure your system to access this repository.
                           rpm-build kvm python-psutil python-ethtool \
                           python-ipaddr python-lxml nfs-client open-iscsi \
                           libxslt-tools python-xml python-parted nginx \
-                          python-libguestfs guestfs-tools python-requests
+                          python-libguestfs guestfs-tools python-requests \
+                          python-websockify
 
     Packages version requirement:
         python-psutil >= 0.6.0
diff --git a/src/kimchi/server.py b/src/kimchi/server.py
index 775313c..8d166e5 100644
--- a/src/kimchi/server.py
+++ b/src/kimchi/server.py
@@ -129,7 +129,7 @@ class Server(object):
 
         if isinstance(model_instance, model.Model):
             vnc_ws_proxy = vnc.new_ws_proxy()
-            cherrypy.engine.subscribe('exit', vnc_ws_proxy.kill)
+            cherrypy.engine.subscribe('exit', vnc_ws_proxy.terminate)
 
         for ident, node in sub_nodes.items():
             if node.url_auth:
diff --git a/src/kimchi/vnc.py b/src/kimchi/vnc.py
index cfa7c6d..66f0fcc 100644
--- a/src/kimchi/vnc.py
+++ b/src/kimchi/vnc.py
@@ -21,8 +21,9 @@
 import base64
 import errno
 import os
-import subprocess
 
+from multiprocessing import Process
+from websockify import WebSocketProxy
 
 from kimchi.config import config, paths
 
@@ -43,13 +44,18 @@ def new_ws_proxy():
         cert = '%s/kimchi-cert.pem' % paths.conf_dir
         key = '%s/kimchi-key.pem' % paths.conf_dir
 
-    cmd = os.path.join(os.path.dirname(__file__), 'websockify.py')
-    args = ['python', cmd, config.get('display', 'display_proxy_port'),
-            '--target-config', WS_TOKENS_DIR, '--cert', cert, '--key', key,
-            '--web', os.path.join(paths.ui_dir, 'pages/websockify'),
-            '--ssl-only']
-    p = subprocess.Popen(args, close_fds=True)
-    return p
+    params = {'web': os.path.join(paths.ui_dir, 'pages/websockify'),
+              'listen_port': config.get('display', 'display_proxy_port'),
+              'target_cfg': WS_TOKENS_DIR,
+              'key': key, 'cert': cert, 'ssl_only': True}
+
+    def start_proxy():
+        server = WebSocketProxy(**params)
+        server.start_server()
+
+    proc = Process(target=start_proxy)
+    proc.start()
+    return proc
 
 
 def add_proxy_token(name, port):
-- 
1.9.3




More information about the Kimchi-devel mailing list