From nobody Fri Mar 29 01:33:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) client-ip=66.187.230.42; envelope-from=kimchi-devel-bounces@ovirt.org; helo=lists.ovirt.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) smtp.mailfrom=kimchi-devel-bounces@ovirt.org; Return-Path: Received: from lists.ovirt.org (lists.phx.ovirt.org [66.187.230.42]) by mx.zohomail.com with SMTPS id 1489152130601530.5514206592425; Fri, 10 Mar 2017 05:22:10 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id 9C12F8205D8; Fri, 10 Mar 2017 13:22:09 +0000 (UTC) Received: from mail-qk0-f194.google.com (mail-qk0-f194.google.com [209.85.220.194]) by lists.ovirt.org (Postfix) with ESMTPS id 8858082058D for ; Fri, 10 Mar 2017 13:21:43 +0000 (UTC) Received: by mail-qk0-f194.google.com with SMTP id n141so27062580qke.3 for ; Fri, 10 Mar 2017 05:21:43 -0800 (PST) Received: from localhost.localdomain ([187.113.144.220]) by smtp.gmail.com with ESMTPSA id w184sm6349263qkc.6.2017.03.10.05.21.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Mar 2017 05:21:42 -0800 (PST) X-Original-To: kimchi-devel@ovirt.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mN2cSt79eRUnFNvoKOr+J1ZDdNJkyvVfHaROOHbhoXQ=; b=LcSPR2AL1dt6dUFrBVZWABwb6++miPEloE/BXR97ERbDxW/+JsxctsgFUX4B8EtPsS NF350gqpi59R5MdXcllee8D4U4UmCyLWwZ9AUGEGCnzlYdqKYhCiwNb8b0nqKuJptGAd uGAR0vmZafhYc2HXmq2lem7o2lVCnrEK65Jsnai0ITxdBrdQuKTB3LovjpHYVfI460+E OiazkiT455WM2VwJFLvPD3EEwOzc4Y7ldUPEFUdB3DQu4iI/MvbkOJm3ZqEQcGGlZkBk 3leU5PBDhyVR70SOLhK/S3Xd5Strr90v26iVrgTpD8KaSmGN837lZDZQwVAaDblNvFCF PY2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mN2cSt79eRUnFNvoKOr+J1ZDdNJkyvVfHaROOHbhoXQ=; b=jo89bnJ8of2y1ai66jRi0QhwGaVHYfRXvoPIbVq7fSzRxEV53SLXOzRQ3znW/Jpbeg VY2RIEFm+QOkA8LUUClwPGYsrTxaS7mkg81U0RK1jgTWDbv5HeWNDhqQ4xO5EPsewREf tmtSy2KdGsiuY2Ww//jxKQpZIcBc2mUNyAd+ErU0NEfevGeMVhm7FXTjWwI+eYGh/hBd WTqilqHU0eMRg4052K64cDCMuh5rVo1gt+1faoF+3+wsi04QiqA28Gh6+l8/H50Lmw5Z 9mxAwSyDCnQHMPoxtkWmO/t6qQ+qI3kkm/0hdsfSJxupuDjcmovPRkUxPh+u7gqkBvTw 3lCQ== X-Gm-Message-State: AMke39nSnuXX7ulTf+a63mR++UNIHSY6j5szl4HUZwhO9Cimg/US4OvCy1FjSE8X0Ayfng== X-Received: by 10.237.55.99 with SMTP id i90mr18996792qtb.262.1489152102457; Fri, 10 Mar 2017 05:21:42 -0800 (PST) From: To: Kimchi Devel Date: Fri, 10 Mar 2017 10:21:32 -0300 Message-Id: <20170310132132.26352-2-dhbarboza82@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170310132132.26352-1-dhbarboza82@gmail.com> References: <20170310132132.26352-1-dhbarboza82@gmail.com> Subject: [Kimchi-devel] [PATCH] [Kimchi] Use Websocket facilities from WoK X-BeenThere: kimchi-devel@ovirt.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: kimchi-devel-bounces@ovirt.org Errors-To: kimchi-devel-bounces@ovirt.org X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza The 'websocket' module was moved from Kimchi to WoK to allow WoK and all its plug-ins to have websocket capabilities. This patch removes the existing websocket module inside Kimchi and updates all the references to use the WoK module instead. The initialization of the ws_proxy was also removed from root.py - this process is also being done by WoK now. Signed-off-by: Daniel Henrique Barboza --- contrib/DEBIAN/control.in | 1 - contrib/kimchi.spec.fedora.in | 1 - contrib/kimchi.spec.suse.in | 1 - docs/fedora-deps.md | 2 +- docs/opensuse-deps.md | 3 +- docs/ubuntu-deps.md | 2 +- model/vms.py | 2 +- root.py | 4 +- websocket.py | 121 --------------------------------------= ---- 9 files changed, 5 insertions(+), 132 deletions(-) delete mode 100644 websocket.py diff --git a/contrib/DEBIAN/control.in b/contrib/DEBIAN/control.in index 6cfd8ee..607b4a5 100644 --- a/contrib/DEBIAN/control.in +++ b/contrib/DEBIAN/control.in @@ -7,7 +7,6 @@ Depends: wok (>=3D 2.1.0), ginger-base, python-imaging, python-configobj, - websockify, novnc, python-jsonschema (>=3D 1.3.0), python-libvirt, diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in index 3b33297..3822527 100644 --- a/contrib/kimchi.spec.fedora.in +++ b/contrib/kimchi.spec.fedora.in @@ -14,7 +14,6 @@ Requires: gettext Requires: libvirt Requires: libvirt-python Requires: libvirt-daemon-config-network -Requires: python-websockify Requires: python-configobj Requires: novnc Requires: python-pillow diff --git a/contrib/kimchi.spec.suse.in b/contrib/kimchi.spec.suse.in index 94dc55e..7a89d6e 100644 --- a/contrib/kimchi.spec.suse.in +++ b/contrib/kimchi.spec.suse.in @@ -14,7 +14,6 @@ Requires: gettext-tools Requires: libvirt Requires: libvirt-python Requires: libvirt-daemon-config-network -Requires: python-websockify Requires: python-configobj Requires: novnc Requires: python-Pillow diff --git a/docs/fedora-deps.md b/docs/fedora-deps.md index 65ad987..1506aa5 100644 --- a/docs/fedora-deps.md +++ b/docs/fedora-deps.md @@ -28,7 +28,7 @@ Runtime Dependencies $ sudo yum install libvirt-python libvirt libvirt-daemon-config-networ= k \ qemu-kvm python-ethtool sos python-ipaddr nfs-util= s \ iscsi-initiator-utils pyparted python-libguestfs \ - libguestfs-tools python-websockify novnc spice-htm= l5 \ + libguestfs-tools novnc spice-html5 \ python-configobj python-magic python-paramiko \ python-pillow =20 diff --git a/docs/opensuse-deps.md b/docs/opensuse-deps.md index 1c5fc23..995a842 100644 --- a/docs/opensuse-deps.md +++ b/docs/opensuse-deps.md @@ -33,8 +33,7 @@ Runtime Dependencies python-ipaddr libvirt-daemon-config-network \ nfs-client open-iscsi python-parted \ python-libguestfs python-configobj guestfs-too= ls \ - python-websockify novnc python-magic \ - python-paramiko python-Pillow + novnc python-magic python-paramiko python-Pill= ow =20 Packages required for UI development ------------------------------------ diff --git a/docs/ubuntu-deps.md b/docs/ubuntu-deps.md index f88eb51..687a9f9 100644 --- a/docs/ubuntu-deps.md +++ b/docs/ubuntu-deps.md @@ -15,7 +15,7 @@ Build Dependencies Runtime Dependencies -------------------- =20 - $ sudo apt-get install python-configobj websockify novnc python-libvir= t \ + $ sudo apt-get install python-configobj novnc python-libvirt \ libvirt-bin nfs-common qemu-kvm python-parted \ python-ethtool sosreport python-ipaddr \ python-lxml open-iscsi python-guestfs \ diff --git a/model/vms.py b/model/vms.py index e7ed7c2..6da4f3b 100644 --- a/model/vms.py +++ b/model/vms.py @@ -36,6 +36,7 @@ from lxml import etree, objectify from lxml.builder import E from xml.etree import ElementTree =20 +from wok import websocket from wok.asynctask import AsyncTask from wok.config import config from wok.exception import InvalidOperation, InvalidParameter @@ -48,7 +49,6 @@ from wok.xmlutils.utils import dictize, xpath_get_text, x= ml_item_insert from wok.xmlutils.utils import xml_item_remove, xml_item_update =20 from wok.plugins.kimchi import model -from wok.plugins.kimchi import websocket from wok.plugins.kimchi import serialconsole from wok.plugins.kimchi.config import READONLY_POOL_TYPE, get_kimchi_versi= on from wok.plugins.kimchi.kvmusertests import UserTests diff --git a/root.py b/root.py index 5ba4f68..4f131e7 100644 --- a/root.py +++ b/root.py @@ -22,7 +22,7 @@ import json import os import tempfile =20 -from wok.plugins.kimchi import config, mockmodel, websocket +from wok.plugins.kimchi import config, mockmodel from wok.plugins.kimchi.i18n import messages from wok.plugins.kimchi.control import sub_nodes from wok.plugins.kimchi.model import model as kimchiModel @@ -59,8 +59,6 @@ class Kimchi(WokRoot): cherrypy.engine.subscribe('exit', remove_objectstore) else: self.model =3D kimchiModel.Model() - ws_proxy =3D websocket.new_ws_proxy() - cherrypy.engine.subscribe('exit', ws_proxy.terminate) =20 dev_env =3D wok_options.environment !=3D 'production' super(Kimchi, self).__init__(self.model, dev_env) diff --git a/websocket.py b/websocket.py deleted file mode 100644 index 6268c8a..0000000 --- a/websocket.py +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/env python2 -# -# Project Kimchi -# -# Copyright IBM Corp, 2016 -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130= 1 USA - -import base64 -import errno -import os - -from multiprocessing import Process -from websockify import WebSocketProxy - -from wok.config import config, PluginPaths - - -try: - from websockify.token_plugins import TokenFile - tokenFile =3D True -except ImportError: - tokenFile =3D False - -try: - from websockify import ProxyRequestHandler as request_proxy -except: - from websockify import WebSocketProxy as request_proxy - - -WS_TOKENS_DIR =3D os.path.join(PluginPaths('kimchi').state_dir, 'ws-tokens= ') - - -class CustomHandler(request_proxy): - - def get_target(self, target_plugin, path): - if issubclass(CustomHandler, object): - target =3D super(CustomHandler, self).get_target(target_plugin, - path) - else: - target =3D request_proxy.get_target(self, target_plugin, path) - - if target[0] =3D=3D 'unix_socket': - try: - self.server.unix_target =3D target[1] - except: - self.unix_target =3D target[1] - else: - try: - self.server.unix_target =3D None - except: - self.unix_target =3D None - return target - - -def new_ws_proxy(): - try: - os.makedirs(WS_TOKENS_DIR, mode=3D0755) - except OSError as e: - if e.errno =3D=3D errno.EEXIST: - pass - - params =3D {'listen_host': '127.0.0.1', - 'listen_port': config.get('server', 'websockets_port'), - 'ssl_only': False} - - # old websockify: do not use TokenFile - if not tokenFile: - params['target_cfg'] =3D WS_TOKENS_DIR - - # websockify 0.7 and higher: use TokenFile - else: - params['token_plugin'] =3D TokenFile(src=3DWS_TOKENS_DIR) - - def start_proxy(): - try: - server =3D WebSocketProxy(RequestHandlerClass=3DCustomHandler, - **params) - except TypeError: - server =3D CustomHandler(**params) - - server.start_server() - - proc =3D Process(target=3Dstart_proxy) - proc.start() - return proc - - -def add_proxy_token(name, port, is_unix_socket=3DFalse): - with open(os.path.join(WS_TOKENS_DIR, name), 'w') as f: - """ - From python documentation base64.urlsafe_b64encode(s) - substitutes - instead of + and _ instead of / in the - standard Base64 alphabet, BUT the result can still - contain =3D which is not safe in a URL query component. - So remove it when needed as base64 can work well without it. - """ - name =3D base64.urlsafe_b64encode(name).rstrip('=3D') - if is_unix_socket: - f.write('%s: unix_socket:%s' % (name.encode('utf-8'), port)) - else: - f.write('%s: localhost:%s' % (name.encode('utf-8'), port)) - - -def remove_proxy_token(name): - try: - os.unlink(os.path.join(WS_TOKENS_DIR, name)) - except OSError: - pass --=20 2.9.3 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel